Skip to content

Commit 959bfad

Browse files
author
Sumedh Wale
committed
skip IP address when hostname-for-clients has been provided
for cases where client-bind-address is an internal IP address (behind a firewall) or 0.0.0.0 etc, then adding the IP address to hostname-for-clients specified value can result in incorrect client behaviour, so skip adding IP address for such cases updated FabricServerTest for the above change
1 parent 185e02c commit 959bfad

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4130,7 +4130,7 @@ else if (re != null && owner.isUsedForPartitionedRegionBucket()) {
41304130
// No need here to close the region etc, the asynch shutdown thread spawned in diskstore will do
41314131
// Moreover for non tx threads this exception is not expected, for Tx threads let this exception
41324132
// cause rollback
4133-
assert noTxn;
4133+
// assert noTxn;
41344134
result = null;
41354135
//owner.handleDiskAccessException(dae, true/* stop bridge servers*/);
41364136
throw dae;

gemfirexd/core/src/main/java/com/pivotal/gemfirexd/internal/engine/fabricservice/FabricServiceImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,8 @@ public abstract class NetworkInterfaceImpl implements NetworkInterface,
879879

880880
protected InetAddress inetAddress;
881881

882+
protected volatile String hostNameForClients;
883+
882884
protected volatile String hostName;
883885

884886
protected int port;
@@ -1100,7 +1102,8 @@ public final String asString() {
11001102
public final String getHostName() {
11011103
final String hostName = getHostNameForClients();
11021104
if (hostName != null) {
1103-
return hostName;
1105+
return this.hostNameForClients != null ? this.hostNameForClients
1106+
: hostName + '/' + this.inetAddress.getHostAddress();
11041107
}
11051108
return "/" + this.inetAddress.getHostAddress();
11061109
}
@@ -1145,6 +1148,7 @@ protected final String setHostNameForClients(Properties networkProps) {
11451148
Attribute.HOSTNAME_FOR_CLIENTS, GfxdConstants.GFXD_PREFIX +
11461149
Attribute.HOSTNAME_FOR_CLIENTS, monitorlite);
11471150
if (host != null) {
1151+
this.hostNameForClients = host;
11481152
this.hostName = host;
11491153
return host;
11501154
}
@@ -1157,7 +1161,8 @@ protected final String setHostNameForClients(Properties networkProps) {
11571161
try {
11581162
final InetAddress localHost = SocketCreator.getLocalHost();
11591163
if (localHost != null && !localHost.isLoopbackAddress()) {
1160-
return (this.hostName = getHostFromInetAddress(localHost));
1164+
this.hostNameForClients = getHostFromInetAddress(localHost);
1165+
return (this.hostName = this.hostNameForClients);
11611166
}
11621167
} catch (UnknownHostException uhe) {
11631168
// ignored

gemfirexd/tools/src/test/java/com/pivotal/gemfirexd/internal/engine/FabricServerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ public void testLocatorStartupAPI() throws Exception {
914914
}
915915
String netStr = rs.getString(3);
916916
assertTrue("Unexpected network server address " + netStr,
917-
netStr.endsWith("/0.0.0.0[" + netPort + ']'));
917+
netStr.endsWith("[" + netPort + ']') && !netStr.contains("/0.0.0.0"));
918918
assertFalse("expected no more than one row from SYS.MEMBERS", rs.next());
919919
} finally {
920920
try {

0 commit comments

Comments
 (0)