This is an automated email from the ASF dual-hosted git repository.
rzo1 pushed a commit to branch tomee-10.x
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/tomee-10.x by this push:
new 415fc63cf9 Fix potential NPE in MulticastPulseClient cf.
https://github.com/apache/tomee/pull/2521#discussion_r2853746157
415fc63cf9 is described below
commit 415fc63cf93d01bb9910f848f8c572544c38f315
Author: Richard Zowalla <[email protected]>
AuthorDate: Wed Feb 25 20:41:00 2026 +0100
Fix potential NPE in MulticastPulseClient
cf. https://github.com/apache/tomee/pull/2521#discussion_r2853746157
---
.../openejb/client/MulticastPulseClient.java | 66 +++++++++++-----------
1 file changed, 34 insertions(+), 32 deletions(-)
diff --git
a/server/openejb-client/src/main/java/org/apache/openejb/client/MulticastPulseClient.java
b/server/openejb-client/src/main/java/org/apache/openejb/client/MulticastPulseClient.java
index 7c8da5ed10..de81faa7c6 100644
---
a/server/openejb-client/src/main/java/org/apache/openejb/client/MulticastPulseClient.java
+++
b/server/openejb-client/src/main/java/org/apache/openejb/client/MulticastPulseClient.java
@@ -681,51 +681,53 @@ public class MulticastPulseClient extends
MulticastConnectionFactory {
System.err.println(e.getMessage());
}
- final int size = uriSet.size();
- if (uriSet != null && size > 0) {
+ if(uriSet != null) {
+ final int size = uriSet.size();
+ if (size > 0) {
- final int st = (timeout / size);
+ final int st = (timeout / size);
- for (final URI uri : uriSet) {
+ for (final URI uri : uriSet) {
- final String server = uri.getScheme().replace("mp-",
"");
- URI uriSub = URI.create(uri.getSchemeSpecificPart());
+ final String server =
uri.getScheme().replace("mp-", "");
+ URI uriSub =
URI.create(uri.getSchemeSpecificPart());
- final String group = uriSub.getScheme();
- uriSub = URI.create(uriSub.getSchemeSpecificPart());
+ final String group = uriSub.getScheme();
+ uriSub =
URI.create(uriSub.getSchemeSpecificPart());
- final String host = uriSub.getHost();
- final int port = uriSub.getPort();
+ final String host = uriSub.getHost();
+ final int port = uriSub.getPort();
- if (MulticastPulseClient.isLocalAddress(host, false)
&& !MulticastPulseClient.isLocalAddress(server, false)) {
- System.out.println(server + ":" + group + " - " +
uriSub.toASCIIString() + " is not a local service");
- continue;
- }
+ if (MulticastPulseClient.isLocalAddress(host,
false) && !MulticastPulseClient.isLocalAddress(server, false)) {
+ System.out.println(server + ":" + group + " -
" + uriSub.toASCIIString() + " is not a local service");
+ continue;
+ }
- System.out.print(server + ":" + group + " - " +
uriSub.toASCIIString() + " is reachable: ");
+ System.out.print(server + ":" + group + " - " +
uriSub.toASCIIString() + " is reachable: ");
- boolean b = false;
- final Socket s = new Socket();
- try {
- s.connect(new InetSocketAddress(host, port), st);
- b = true;
- } catch (Exception e) {
- if
(java.net.SocketTimeoutException.class.isInstance(e) ||
SocketException.class.isInstance(e)) {
- MulticastPulseClient.broadcastBadUri(group,
uriSub, mchost, mcport);
- System.out.print("" + e + " : ");
- }
- } finally {
+ boolean b = false;
+ final Socket s = new Socket();
try {
- s.close();
+ s.connect(new InetSocketAddress(host, port),
st);
+ b = true;
} catch (Exception e) {
- //Ignore
+ if
(java.net.SocketTimeoutException.class.isInstance(e) ||
SocketException.class.isInstance(e)) {
+
MulticastPulseClient.broadcastBadUri(group, uriSub, mchost, mcport);
+ System.out.print("" + e + " : ");
+ }
+ } finally {
+ try {
+ s.close();
+ } catch (Exception e) {
+ //Ignore
+ }
}
- }
- System.out.println(b);
+ System.out.println(b);
+ }
+ } else {
+ System.out.println("### Failed to discover server: " +
discover);
}
- } else {
- System.out.println("### Failed to discover server: " +
discover);
}
System.out.println(".");