3030import java .util .List ;
3131import java .util .concurrent .TimeUnit ;
3232
33+ import org .jgroups .Address ;
3334import org .jgroups .Event ;
3435import org .jgroups .Message ;
3536import org .jgroups .annotations .Property ;
@@ -67,6 +68,7 @@ public abstract class OpenshiftPing extends PING {
6768 private String _serverName ;
6869
6970 private static Method sendMethod ; //handled via reflection due to JGroups 3/4 incompatibility
71+ private static Method setSrcMethod ;
7072
7173 public OpenshiftPing (String systemEnvPrefix ) {
7274 super ();
@@ -80,6 +82,12 @@ public OpenshiftPing(String systemEnvPrefix) {
8082 } catch (Exception e ) {
8183 throw new CompatibilityException ("Could not find suitable 'up' method." , e );
8284 }
85+ try {
86+ //the return parameter changed in JGroups 3/4 :D
87+ setSrcMethod = Message .class .getMethod ("setSrc" , Address .class );
88+ } catch (Exception e ) {
89+ throw new CompatibilityException ("Could not find suitable 'setSrc' method." , e );
90+ }
8391 }
8492
8593 protected final String getSystemEnvName (String systemEnvSuffix ) {
@@ -194,7 +202,7 @@ protected void sendMcastDiscoveryRequest(Message msg) {
194202 return ;
195203 }
196204 if (msg .getSrc () == null ) {
197- msg . setSrc (local_addr );
205+ setSrc (msg );
198206 }
199207 for (InetSocketAddress node : nodes ) {
200208 // forward the request to each node
@@ -213,6 +221,16 @@ public void handlePingRequest(InputStream stream) throws Exception {
213221 }
214222 }
215223
224+ private void setSrc (Message msg ) {
225+ try {
226+ setSrcMethod .invoke (msg , local_addr );
227+ } catch (IllegalAccessException e ) {
228+ e .printStackTrace ();
229+ } catch (Exception e ) {
230+ throw new CompatibilityException ("Could not invoke 'setSrc' method." , e );
231+ }
232+ }
233+
216234 private void sendUp (Message msg ) {
217235 try {
218236 if (CompatibilityUtils .isJGroups4 ()) {
0 commit comments