Skip to content

Commit

Permalink
Merge pull request payara#3727 from Pandrex247/PAYARA-3478-SO_KEEPALI…
Browse files Browse the repository at this point in the history
…VE-Wrong-port-and-logic

PAYARA-3478 Fix Port Usage and Logic in PAYARA-546
  • Loading branch information
Pandrex247 committed Feb 22, 2019
1 parent 6de44d0 commit 6957a26
Showing 1 changed file with 30 additions and 9 deletions.
Expand Up @@ -656,22 +656,26 @@ private void enableSOKeepAliveAsRequired(Socket socket) throws SocketException {

// For each listener, find one with a matching port
for (IiopListener iiopListener : iiopService.getIiopListener()) {
if (Integer.valueOf(iiopListener.getPort()) == socket.getPort()) {
if (Integer.valueOf(iiopListener.getPort()) == socket.getLocalPort()) {
// Check for the property globally before checking on the specific listener, giving precedence to the
// new property
if ((System.getProperty(SO_KEEPALIVE) == null && Boolean.getBoolean(SO_KEEPALIVE_DEPRECATED))
|| Boolean.getBoolean(SO_KEEPALIVE)) {
// Check if we should override the global value
if (soKeepAliveEnabledOnIiopListener(iiopListener)) {
shouldSet = true;
// Check if the property has been set on the listener
if (soKeepAlivePropertyPresentOnIiopListener(iiopListener)) {
// Check if we should override the global value
if (soKeepAlivePropertyEnabledOnIiopListener(iiopListener)) {
shouldSet = true;
}
} else {
// If the property wasn't set on the listener, go with the global setting
shouldSet = true;
}
break;
} else {
// If it wasn't set globally, just check if it's set on the listener
if (soKeepAliveEnabledOnIiopListener(iiopListener)) {
// If it wasn't set globally, just check if it's set and enabled on the listener
if (soKeepAlivePropertyPresentOnIiopListener(iiopListener)
&& soKeepAlivePropertyEnabledOnIiopListener(iiopListener)) {
shouldSet = true;
}
break;
Expand All @@ -692,12 +696,29 @@ private void enableSOKeepAliveAsRequired(Socket socket) throws SocketException {
}

/**
* Helper method that checks if either the deprecated or new SO_KEEPALIVE property is present and enabled on an IIOP
* Shorthand method that simply returns true if either the new or old SO_KEEPALIVE property is present on the
* listener.
* @param iiopListener The IIOP listener to check if the SO_KEEPALIVE property is set on
* @return True if the SO_KEEPALIVE property is present on the IIOP listener
*/
private boolean soKeepAlivePropertyPresentOnIiopListener(IiopListener iiopListener) {
boolean soKeepAlivePropertyPresentOnListener = false;

if (iiopListener.getPropertyValue(SO_KEEPALIVE) != null
|| iiopListener.getPropertyValue(SO_KEEPALIVE_DEPRECATED) != null) {
soKeepAlivePropertyPresentOnListener = true;
}

return soKeepAlivePropertyPresentOnListener;
}

/**
* Helper method that checks if either the deprecated or new SO_KEEPALIVE property is enabled on an IIOP
* listener, giving precedence to the new property if both are present.
* @param iiopListener The IIOP listener to check if the SO_KEEPALIVE property is set on
* @return True if the SO_KEEPALIVE property is present and enabled on the IIOP listener
* @return True if the SO_KEEPALIVE property is enabled on the IIOP listener
*/
private boolean soKeepAliveEnabledOnIiopListener(IiopListener iiopListener) {
private boolean soKeepAlivePropertyEnabledOnIiopListener(IiopListener iiopListener) {
boolean soKeepAliveEnabledOnListener = false;

// If the new property isn't present and the deprecated one is set to true, or if the new property is set to
Expand Down

0 comments on commit 6957a26

Please sign in to comment.