Skip to content

Commit 8132bf3

Browse files
committed
Static constructor
1 parent c565f89 commit 8132bf3

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

server/src/main/java/org/elasticsearch/transport/TransportService.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,20 @@ public class TransportService extends AbstractLifecycleComponent
8181
private static final Logger logger = LogManager.getLogger(TransportService.class);
8282

8383
private static final String PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS_KEY = "es.unsafely_permit_handshake_from_incompatible_builds";
84-
private static final boolean PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS = getPermitHandshakesFromIncompatibleBuilds();
84+
private static final boolean PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS;
85+
86+
static {
87+
final String value = System.getProperty(PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS_KEY);
88+
if (value == null) {
89+
PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS = false;
90+
} else if (Boolean.parseBoolean(value)) {
91+
PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS = true;
92+
} else {
93+
throw new IllegalArgumentException("invalid value [" + value + "] for system property ["
94+
+ PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS_KEY + "]");
95+
}
96+
}
97+
8598

8699
public static final String DIRECT_RESPONSE_PROFILE = ".direct";
87100
public static final String HANDSHAKE_ACTION_NAME = "internal:transport/handshake";
@@ -1440,16 +1453,4 @@ public void onResponseReceived(long requestId, Transport.ResponseContext holder)
14401453
}
14411454
}
14421455

1443-
private static boolean getPermitHandshakesFromIncompatibleBuilds() {
1444-
final String value = System.getProperty(PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS_KEY);
1445-
if (value == null) {
1446-
return false;
1447-
}
1448-
if (Boolean.parseBoolean(value)) {
1449-
return true;
1450-
}
1451-
throw new IllegalArgumentException("invalid value [" + value + "] for system property ["
1452-
+ PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS_KEY + "]");
1453-
}
1454-
14551456
}

0 commit comments

Comments
 (0)