kirklund commented on a change in pull request #6866:
URL: https://github.com/apache/geode/pull/6866#discussion_r709455921



##########
File path: 
geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/pubsub/PubSubNativeRedisAcceptanceTest.java
##########
@@ -25,20 +31,48 @@
 public class PubSubNativeRedisAcceptanceTest extends 
AbstractPubSubIntegrationTest {
 
   private static final Logger logger = LogService.getLogger();
+  private static long socketTimeWaitMsec = 240000;
 
   @ClassRule
   public static NativeRedisTestRule redis = new NativeRedisTestRule();
 
+  @BeforeClass
+  public static void runOnce() throws IOException {
+    if (SystemUtils.IS_OS_LINUX) {
+      try {
+        String line = getCommandOutput("cat 
/proc/sys/net/ipv4/tcp_fin_timeout");
+        socketTimeWaitMsec = Long.parseLong(line.trim());
+      } catch (NumberFormatException | IOException ignored) {
+      }
+    } else if (SystemUtils.IS_OS_MAC) {
+      try {
+        String line = getCommandOutput("sysctl net.inet.tcp.msl");
+        String[] parts = line.split(":");
+        if (parts.length == 2) {
+          socketTimeWaitMsec = 2 * Long.parseLong(parts[1].trim());
+        }
+      } catch (NumberFormatException | IOException ignored) {
+      }
+    }
+    // Just leave timeout at the default if it's some other OS or there's a 
problem getting OS value
+  }
+
+  private static String getCommandOutput(String commandString) throws 
IOException {
+    Process process = Runtime.getRuntime().exec(commandString);
+    BufferedReader reader = new BufferedReader(
+        new InputStreamReader(process.getInputStream()));
+    return reader.readLine();
+  }

Review comment:
       You should probably update to using `ProcessBuilder` and 
try-with-resources for the `InputStream`:
   ```java
   Process process = new ProcessBuilder(commandString).start();
   try (BufferedReader reader = new BufferedReader(
       new InputStreamReader(process.getInputStream()))) {
     return reader.readLine();
   } finally {
     // probably not necessary but just to be sure test leaves no orphaned 
process
     process.destroy();
   }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to