Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2004-2008 Jive Software, 2016-2025 Ignite Realtime Foundation. All rights reserved.
* Copyright (C) 2004-2008 Jive Software, 2016-2026 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 @@ -124,7 +124,7 @@ public HistoryStrategy(JID roomJID, HistoryStrategy parentStrategy) {
maxNumber = DEFAULT_MAX_NUMBER;
}
else {
type = Type.defaulType;
type = Type.defaultType;
maxNumber = parent.getMaxNumber();
}
}
Expand Down Expand Up @@ -205,16 +205,9 @@ public void addMessage(@Nonnull final Message... packets)
}

// get the conditions based on default or not
final Type strategyType;
final int strategyMaxNumber;
if (type == Type.defaulType && parent != null) {
strategyType = parent.getType();
strategyMaxNumber = parent.getMaxNumber();
}
else {
strategyType = type;
strategyMaxNumber = maxNumber;
}
final HistoryStrategy effective = resolveEffective();
final Type strategyType = effective.getType();
final int strategyMaxNumber = effective.getMaxNumber();

final Lock lock = MUC_HISTORY_CACHE.getLock(roomJID);
lock.lock();
Expand All @@ -238,11 +231,7 @@ public void addMessage(@Nonnull final Message... packets)
}

boolean isHistoryEnabled() {
Type strategyType = type;
if (type == Type.defaulType && parent != null) {
strategyType = parent.getType();
}
return strategyType != HistoryStrategy.Type.none;
return resolveEffective().getType() != Type.none;
}

/**
Expand Down Expand Up @@ -321,6 +310,21 @@ public void purge()
}
}

/**
* Resolves this strategy to the one whose settings are actually in effect: if this strategy's type is
* {@link Type#defaultType}, walks up the parent chain until a strategy with a concrete type (or no parent) is found.
* Returns this instance if its type is not defaultType, or if it has no parent to defer to.
*
* @return The strategy instance whose type/maxNumber values should be treated as authoritative.
*/
HistoryStrategy resolveEffective() {
HistoryStrategy strategy = this;
while (strategy.type == Type.defaultType && strategy.parent != null) {
strategy = strategy.parent;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
return strategy;
}

@Override
public void writeExternal(ObjectOutput out) throws IOException {
ExternalizableUtil.getInstance().writeSerializable(out, type);
Expand Down Expand Up @@ -383,7 +387,7 @@ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundExcept
* Strategy type.
*/
public enum Type {
defaulType, none, all, number;
defaultType, none, all, number;
Comment thread
Fishbowler marked this conversation as resolved.
}

/**
Expand All @@ -400,7 +404,7 @@ public void setTypeFromString(String typeName) {
}
catch (Exception e) {
if (parent != null) {
type = Type.defaulType;
type = Type.defaultType;
}
else {
type = Type.number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2004-2008 Jive Software, 2016-2025 Ignite Realtime Foundation. All rights reserved.
* Copyright (C) 2004-2008 Jive Software, 2016-2026 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 @@ -290,7 +290,7 @@
*/
@Deprecated(forRemoval = true) // Remove in or after Openfire 5.2.0
public boolean hasChangedSubject() {
return historyStrategy.hasChangedSubject();

Check warning on line 293 in xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java

View workflow job for this annotation

GitHub Actions / Analyze (java)

hasChangedSubject() in org.jivesoftware.openfire.muc.HistoryStrategy has been deprecated and marked for removal

Check warning on line 293 in xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java

View workflow job for this annotation

GitHub Actions / Build Openfire from source (ubuntu-latest, 25, zulu)

hasChangedSubject() in org.jivesoftware.openfire.muc.HistoryStrategy has been deprecated and marked for removal

Check warning on line 293 in xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java

View workflow job for this annotation

GitHub Actions / Build Openfire from source (macos-latest, 25, zulu)

hasChangedSubject() in org.jivesoftware.openfire.muc.HistoryStrategy has been deprecated and marked for removal

Check warning on line 293 in xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java

View workflow job for this annotation

GitHub Actions / Build Openfire from source (macos-latest, 17, zulu)

hasChangedSubject() in org.jivesoftware.openfire.muc.HistoryStrategy has been deprecated and marked for removal

Check warning on line 293 in xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java

View workflow job for this annotation

GitHub Actions / Build Openfire from source (ubuntu-latest, 21, zulu)

hasChangedSubject() in org.jivesoftware.openfire.muc.HistoryStrategy has been deprecated and marked for removal

Check warning on line 293 in xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java

View workflow job for this annotation

GitHub Actions / Build Openfire from source (ubuntu-latest, 17, zulu)

hasChangedSubject() in org.jivesoftware.openfire.muc.HistoryStrategy has been deprecated and marked for removal

Check warning on line 293 in xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java

View workflow job for this annotation

GitHub Actions / Build Openfire from source (macos-latest, 21, zulu)

hasChangedSubject() in org.jivesoftware.openfire.muc.HistoryStrategy has been deprecated and marked for removal
}

/**
Expand All @@ -303,7 +303,7 @@
@Deprecated(forRemoval = true) // Remove in or after Openfire 5.2.0
@Nullable
public Message getChangedSubject() {
return historyStrategy.getChangedSubject();

Check warning on line 306 in xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java

View workflow job for this annotation

GitHub Actions / Analyze (java)

getChangedSubject() in org.jivesoftware.openfire.muc.HistoryStrategy has been deprecated and marked for removal

Check warning on line 306 in xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java

View workflow job for this annotation

GitHub Actions / Build Openfire from source (ubuntu-latest, 25, zulu)

getChangedSubject() in org.jivesoftware.openfire.muc.HistoryStrategy has been deprecated and marked for removal

Check warning on line 306 in xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java

View workflow job for this annotation

GitHub Actions / Build Openfire from source (macos-latest, 25, zulu)

getChangedSubject() in org.jivesoftware.openfire.muc.HistoryStrategy has been deprecated and marked for removal

Check warning on line 306 in xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java

View workflow job for this annotation

GitHub Actions / Build Openfire from source (macos-latest, 17, zulu)

getChangedSubject() in org.jivesoftware.openfire.muc.HistoryStrategy has been deprecated and marked for removal

Check warning on line 306 in xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java

View workflow job for this annotation

GitHub Actions / Build Openfire from source (ubuntu-latest, 21, zulu)

getChangedSubject() in org.jivesoftware.openfire.muc.HistoryStrategy has been deprecated and marked for removal

Check warning on line 306 in xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java

View workflow job for this annotation

GitHub Actions / Build Openfire from source (ubuntu-latest, 17, zulu)

getChangedSubject() in org.jivesoftware.openfire.muc.HistoryStrategy has been deprecated and marked for removal

Check warning on line 306 in xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java

View workflow job for this annotation

GitHub Actions / Build Openfire from source (macos-latest, 21, zulu)

getChangedSubject() in org.jivesoftware.openfire.muc.HistoryStrategy has been deprecated and marked for removal
}

/**
Expand All @@ -324,8 +324,9 @@
* @return The maximum number of historic messages to keep for this room, or -1.
*/
public int getMaxMessages() {
return switch (historyStrategy.getType()) {
case number -> historyStrategy.getMaxNumber();
final HistoryStrategy effective = historyStrategy.resolveEffective();
return switch (effective.getType()) {
case number -> effective.getMaxNumber();
case none -> 0;
default -> -1;
};
Expand Down
Loading