Use new Java features (switch expressions, text blocks, new JDK methods)

Closes gh-29747
This commit is contained in:
Krzysztof Krason
2022-12-28 08:59:08 +01:00
committed by Sam Brannen
parent 48abd493fe
commit afb8a0d1b1
53 changed files with 498 additions and 552 deletions

View File

@@ -365,45 +365,54 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
}
else if (isCacheConsumers()) {
// let raw JMS invocation throw an exception if Destination (i.e. args[0]) is null
if ((methodName.equals("createConsumer") || methodName.equals("createReceiver") ||
methodName.equals("createSubscriber"))) {
Destination dest = (Destination) args[0];
if (dest != null && !(dest instanceof TemporaryQueue || dest instanceof TemporaryTopic)) {
return getCachedConsumer(dest,
(args.length > 1 ? (String) args[1] : null),
(args.length > 2 && (Boolean) args[2]),
null,
false);
switch (methodName) {
case "createConsumer", "createReceiver", "createSubscriber" -> {
Destination dest = (Destination) args[0];
if (dest != null && !(dest instanceof TemporaryQueue || dest instanceof TemporaryTopic)) {
return getCachedConsumer(
dest,
(args.length > 1 ? (String) args[1] : null),
(args.length > 2 && (Boolean) args[2]),
null,
false
);
}
}
}
else if (methodName.equals("createDurableConsumer") || methodName.equals("createDurableSubscriber")) {
Destination dest = (Destination) args[0];
if (dest != null) {
return getCachedConsumer(dest,
(args.length > 2 ? (String) args[2] : null),
(args.length > 3 && (Boolean) args[3]),
(String) args[1],
true);
case "createDurableConsumer", "createDurableSubscriber" -> {
Destination dest = (Destination) args[0];
if (dest != null) {
return getCachedConsumer(
dest,
(args.length > 2 ? (String) args[2] : null),
(args.length > 3 && (Boolean) args[3]),
(String) args[1],
true
);
}
}
}
else if (methodName.equals("createSharedConsumer")) {
Destination dest = (Destination) args[0];
if (dest != null) {
return getCachedConsumer(dest,
(args.length > 2 ? (String) args[2] : null),
null,
(String) args[1],
false);
case "createSharedConsumer" -> {
Destination dest = (Destination) args[0];
if (dest != null) {
return getCachedConsumer(
dest,
(args.length > 2 ? (String) args[2] : null),
null,
(String) args[1],
false
);
}
}
}
else if (methodName.equals("createSharedDurableConsumer")) {
Destination dest = (Destination) args[0];
if (dest != null) {
return getCachedConsumer(dest,
(args.length > 2 ? (String) args[2] : null),
null,
(String) args[1],
true);
case "createSharedDurableConsumer" -> {
Destination dest = (Destination) args[0];
if (dest != null) {
return getCachedConsumer(
dest,
(args.length > 2 ? (String) args[2] : null),
null,
(String) args[1],
true
);
}
}
}
}