Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #43: Prevent ClassCastExceptions after plugin gets reloaded in a cluster #66

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ <h1>HTTP File Upload Plugin Changelog</h1>
<p><b>1.4.1</b> -- (tbd)</p>
<ul>
<li>Updated Ukrainian (uk_UA) translation, by Vladislav Savchuk (Bruhmozavr)</li>
<li><a href="https://github.com/igniterealtime/openfire-httpFileUpload-plugin/issues/43">Issue #43:</a> ClassCastExceptions after reloading plugin in a cluster.</li>
</ul>

<p><b>1.4.0</b> -- (January 19, 2024)</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2022 Ignite Realtime Foundation. All rights reserved.
* Copyright (c) 2017-2024 Ignite Realtime Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,10 +29,11 @@

public class OpenfireSlotProvider implements SlotProvider
{
private final Cache<SecureUniqueId, Slot> slotsCache;
// Use string-representation of SecureUniqueId as cache key, as the interface cannot be processed by JAXB.
private final Cache<String, Slot> slotsCache;

public OpenfireSlotProvider() {
slotsCache = CacheFactory.createCache("HTTP File Upload Slots");
slotsCache = CacheFactory.createSerializingCache("HTTP File Upload Slots", String.class, Slot.class);

// Unless there is specific configuration for this cache, default the max lifetime of entries in this cache to something that's fairly short.
if (null == JiveGlobals.getProperty("cache." + slotsCache.getName().replaceAll(" ", "") + ".maxLifetime")) {
Expand All @@ -43,10 +44,10 @@ public OpenfireSlotProvider() {
@Override
public void create(@Nonnull final Slot slot)
{
final Lock lock = slotsCache.getLock(slot.getUuid());
final Lock lock = slotsCache.getLock(slot.getUuid().toString());
lock.lock();
try {
slotsCache.put( slot.getUuid(), slot );
slotsCache.put( slot.getUuid().toString(), slot );
} finally {
lock.unlock();
}
Expand All @@ -56,10 +57,10 @@ public void create(@Nonnull final Slot slot)
@Override
public Slot consume(@Nonnull final SecureUniqueId slotId)
{
final Lock lock = slotsCache.getLock(slotId);
final Lock lock = slotsCache.getLock(slotId.toString());
lock.lock();
try {
return slotsCache.remove(slotId);
return slotsCache.remove(slotId.toString());
} finally {
lock.unlock();
}
Expand Down