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

ARTEMIS-5302 use QueueConfiguration more #5504

Merged
merged 1 commit into from
Feb 13, 2025

Conversation

jbertram
Copy link
Contributor

There are several places across the code-base that repeat all the configuration parameters of a queue. This commit simplifies the code and increases readability by using o.a.a.a.a.c.QueueConfiguration as often as possible.

There are several places across the code-base that repeat all the
configuration parameters of a queue. This commit simplifies the code
and increases readability by using o.a.a.a.a.c.QueueConfiguration as
often as possible.
@jbertram
Copy link
Contributor Author

My only concern with this PR is that some fields in QueueImpl which were volatile have been replaced with ones from QueueConfiguration which are not. That said, the full test-suite is green on this so it's not clear that actually makes a difference. I would love feedback on this point specifically.

@clebertsuconic
Copy link
Contributor

I looked now and it looks good to me.

I don't think the volatile was needed. The place where it's being used (QueueImpl.addConsumer) is under a synchronized block.

One thing that bothered me was beyond the scope of this PR.. as Queueimpl.addConsumer is called within ServerConsumerImpl... but that goes beyond the scope of this PR.

I don't have any issues with this PR if tests are good

@clebertsuconic clebertsuconic merged commit 00f69a1 into apache:main Feb 13, 2025
6 checks passed
Comment on lines -143 to -147
/**
* @deprecated
* Use {@link #of(String)} instead.
*/
@Deprecated(forRemoval = true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than un-deprecating this, which only encourages its use (either brand new use, or continued use that missed the deprecation during the intermediate versions) instead of all the replacements that have been added, I think you should have left it deprecated and either suppressed the warning for the PersistentQueueBindingEncoding usage, or adjusted PersistentQueueBindingEncoding/its-uses such that those didnt need to call this.

Comment on lines +414 to +418
if (filterString != null && !filterString.isEmpty() && !filterString.isBlank()) {
this.filterString = filterString;
} else if (filterString == null) {
this.filterString = filterString;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems questionable, the setter will silently no-op if passed an empty or blank value, even if an existing value was previously set. So if called with empty or blank when nothing was set, the getter will then return null...and if called after a previous 'populating' set, the getter will then return the old value. In both cases, not matching the value most recently set.

Seems more like it should either allow the set (i.e continue expecting usages to handle the empty/blank return as it originally did), or else always treat empty/blank the same as setting null and clear any existing value.

Comment on lines +45 to +61
public void testBlank() {
for (int i = 0; i <= 10; i++) {
assertTrue(SimpleString.of(" ".repeat(i)).isBlank());
}
for (int i = 0; i <= 10; i++) {
assertTrue(SimpleString.of("\t".repeat(i)).isBlank());
}
for (int i = 0; i <= 10; i++) {
assertTrue(SimpleString.of("\n".repeat(i)).isBlank());
}
for (int i = 0; i <= 10; i++) {
assertTrue(SimpleString.of("\r".repeat(i)).isBlank());
}
for (int i = 1; i <= 10; i++) {
assertFalse(SimpleString.of("x".repeat(i)).isBlank());
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This misses testing various interesting corner cases such as the actual-empty string which is also blank, and having whitespace at start, end, or both but not the whole string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The empty case is already covered by any assertion that uses repeat(0). I'll add the others.

.setAutoCreated(autoCreated)
.setEnabled(enabled)
.setGroupRebalancePauseDispatch(groupRebalancePauseDispatch);
return queueConfiguration;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this method isnt synchronized, switching to this actually is applying a behaviour change around all of those volatile fields that were removed. It will depend on how they and this return value are used specifically what that really means in practice.

@jbertram
Copy link
Contributor Author

@gemmellr, I opened #5507 to deal with the issues you commented on here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants