geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstew...@apache.org
Subject geode git commit: GEODE-2874: Fix StringIndexOutOfBoundsException while initializing logger
Date Thu, 18 May 2017 15:27:35 GMT
Repository: geode
Updated Branches:
  refs/heads/develop 15245dfd2 -> 90ee3d8a0


GEODE-2874: Fix StringIndexOutOfBoundsException while initializing logger


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/90ee3d8a
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/90ee3d8a
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/90ee3d8a

Branch: refs/heads/develop
Commit: 90ee3d8a0f071f83e19f7c28f78e2d470282e0de
Parents: 15245df
Author: Jared Stewart <jstewart@pivotal.io>
Authored: Thu May 18 08:25:30 2017 -0700
Committer: Jared Stewart <jstewart@pivotal.io>
Committed: Thu May 18 08:25:30 2017 -0700

----------------------------------------------------------------------
 .../io/MainWithChildrenRollingFileHandler.java  |  5 +-
 ...WithChildrenRollingFileHandlerDUnitTest.java | 50 ++++++++++++++++++++
 ...ildrenRollingFileHandlerIntegrationTest.java | 11 +++++
 .../dunit/rules/LocatorServerStartupRule.java   |  2 +-
 4 files changed, 66 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/90ee3d8a/geode-core/src/main/java/org/apache/geode/internal/io/MainWithChildrenRollingFileHandler.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/io/MainWithChildrenRollingFileHandler.java
b/geode-core/src/main/java/org/apache/geode/internal/io/MainWithChildrenRollingFileHandler.java
index f814aeb..225d1bf 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/io/MainWithChildrenRollingFileHandler.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/io/MainWithChildrenRollingFileHandler.java
@@ -43,9 +43,12 @@ public class MainWithChildrenRollingFileHandler implements RollingFileHandler
{
     String baseName;
     if (endIdx1 != -1) {
       baseName = file.getName().substring(0, endIdx1);
-    } else {
+    } else if (endIdx2 != -1) {
       baseName = file.getName().substring(0, endIdx2);
+    } else {
+      baseName = file.getName();
     }
+
     File[] children = findChildren(dir, CHILD_ID_PATTERN);
 
     /* Search child logs */

http://git-wip-us.apache.org/repos/asf/geode/blob/90ee3d8a/geode-core/src/test/java/org/apache/geode/internal/io/MainWithChildrenRollingFileHandlerDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/io/MainWithChildrenRollingFileHandlerDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/internal/io/MainWithChildrenRollingFileHandlerDUnitTest.java
new file mode 100644
index 0000000..6032b46
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/io/MainWithChildrenRollingFileHandlerDUnitTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information
regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version
2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain
a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under
the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express
+ * or implied. See the License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+
+package org.apache.geode.internal.io;
+
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
+
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientCacheFactory;
+import org.apache.geode.test.dunit.rules.Locator;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.net.InetAddress;
+
+@Category(DistributedTest.class)
+public class MainWithChildrenRollingFileHandlerDUnitTest {
+
+  @Rule
+  public LocatorServerStartupRule locatorServerStartupRule = new LocatorServerStartupRule();
+
+  @Test
+  public void testGeode2874_nameWithoutExtensionDoesNotThrowOnMemberRestart() throws Exception
{
+    MemberVM<Locator> locatorVM = locatorServerStartupRule.startLocatorVM(0);
+
+    ClientCacheFactory clientCacheFactory = new ClientCacheFactory();
+    clientCacheFactory.addPoolLocator(InetAddress.getLocalHost().toString(), locatorVM.getPort());
+    clientCacheFactory.set(LOG_FILE, "nameWithoutExtension");
+    ClientCache clientCache = clientCacheFactory.create();
+
+    clientCache.close();
+    ClientCache clientCache2 = clientCacheFactory.create();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/90ee3d8a/geode-core/src/test/java/org/apache/geode/internal/io/MainWithChildrenRollingFileHandlerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/io/MainWithChildrenRollingFileHandlerIntegrationTest.java
b/geode-core/src/test/java/org/apache/geode/internal/io/MainWithChildrenRollingFileHandlerIntegrationTest.java
index 5ea77c4..4c7cdfc 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/io/MainWithChildrenRollingFileHandlerIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/io/MainWithChildrenRollingFileHandlerIntegrationTest.java
@@ -16,12 +16,14 @@ package org.apache.geode.internal.io;
 
 import static org.assertj.core.api.Assertions.*;
 
+import java.io.File;
 import java.util.regex.Pattern;
 
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
 import org.junit.rules.TestName;
 
 import org.apache.geode.test.junit.categories.IntegrationTest;
@@ -35,6 +37,9 @@ public class MainWithChildrenRollingFileHandlerIntegrationTest {
   @Rule
   public TestName testName = new TestName();
 
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
   @Before
   public void before() throws Exception {
     this.name = this.testName.getMethodName();
@@ -93,4 +98,10 @@ public class MainWithChildrenRollingFileHandlerIntegrationTest {
         .isInstanceOf(IllegalArgumentException.class);
   }
 
+  @Test
+  public void calcNextChildId_noExtensionInFilename_doesNotThrow() {
+    File file = new File(temporaryFolder.getRoot(), "fileWithoutExtension");
+    assertThat(handler.calcNextChildId(file, 0)).isEqualTo(1);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/90ee3d8a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
index b86e058..055993c 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
@@ -79,7 +79,7 @@ public class LocatorServerStartupRule extends ExternalResource implements
Serial
         .forEach(MemberVM::stopMemberAndCleanupVMIfNecessary);
   }
 
-  public MemberVM startLocatorVM(int index) throws Exception {
+  public MemberVM<Locator> startLocatorVM(int index) throws Exception {
     return startLocatorVM(index, new Properties());
   }
 


Mime
View raw message