[
https://issues.apache.org/jira/browse/GEODE-3038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16261699#comment-16261699
]
ASF GitHub Bot commented on GEODE-3038:
---------------------------------------
agingade closed pull request #677: GEODE-3038: A server process shuts down
quietly when path to cache.xml is incorrect
URL: https://github.com/apache/geode/pull/677
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
index f176d22065..89d8b467c5 100755
---
a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
+++
b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
@@ -1208,6 +1208,9 @@ private void initialize() {
this.system.getConfig());
initializeDeclarativeCache();
completedCacheXml = true;
+ } catch (RuntimeException e) {
+ logger.error("Cache initialization failed because: " + e.toString()); //
fix GEODE-3038
+ throw e;
} finally {
if (!completedCacheXml) {
// so initializeDeclarativeCache threw an exception
diff --git
a/geode-core/src/test/java/org/apache/geode/cache30/CacheXmlNotFoundRegressionTest.java
b/geode-core/src/test/java/org/apache/geode/cache30/CacheXmlNotFoundRegressionTest.java
new file mode 100644
index 0000000000..dc0d26a977
--- /dev/null
+++
b/geode-core/src/test/java/org/apache/geode/cache30/CacheXmlNotFoundRegressionTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.cache30;
+
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.CacheXmlException;
+import org.apache.geode.distributed.ConfigurationProperties;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+import java.util.Properties;
+import java.util.Scanner;
+
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.fail;
+
+@Category(IntegrationTest.class)
+public class CacheXmlNotFoundRegressionTest {
+
+ /**
+ * unit test for <a
href="https://issues.apache.org/jira/browse/GEODE-3038">GEODE-3038</a> Tests
+ * that an error about missing cache-xml file is indeed printed in the text
log file. The test
+ * {@link CacheXml66DUnitTest#testNonExistentFile()} is supposed to test the
same, but is not
+ * enough. It only checks for an CacheXmlException exception to be thrown.
Also in that test a log
+ * is printed into STDOUT, and we do see our error there, but that is not
the case when we work
+ * with the real text log, specified via "log-file" param.
+ */
+ @Test
+ public void testCacheXmlNotFoundInRealLog() throws Exception {
+
+ String CACHE_SERVER_LOG = "cacheXmlNotFoundUnitTest.log";
+ Properties props = new Properties();
+ props.put(ConfigurationProperties.MCAST_PORT, "0");
+ props.put(ConfigurationProperties.LOG_FILE, CACHE_SERVER_LOG);
+ props.put(ConfigurationProperties.CACHE_XML_FILE,
"non-existing-cache-xml");
+
+ CacheFactory factory = new CacheFactory(props);
+
+ String errorMessage = "";
+
+ try {
+ factory.create();
+ fail("Should have thrown a CacheXmlException");
+ } catch (CacheXmlException e) {
+ errorMessage = e.toString();
+ }
+
+ // looking for an error in the text log file
+ Scanner scanner = new Scanner(new File(CACHE_SERVER_LOG));
+
+ boolean found = false;
+ while (scanner.hasNextLine() && !found) {
+ found = scanner.nextLine().contains(errorMessage);
+ }
+ scanner.close();
+ assertTrue("there should be a line about cache-xml-not-found in a log
file", found);
+
+ // deleting a log file
+ File logFile = new File(CACHE_SERVER_LOG);
+ logFile.delete();
+ }
+}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> A server process shuts down quietly when path to cache.xml is incorrect
> -----------------------------------------------------------------------
>
> Key: GEODE-3038
> URL: https://issues.apache.org/jira/browse/GEODE-3038
> Project: Geode
> Issue Type: Bug
> Components: configuration
> Reporter: Anton Mironenko
> Priority: Minor
>
> Geode version: 1.1.1, 1.3.0 (latest develop snapshot)
> If I start a server with incorrect path to Server.xml, it shuts down quietly
> without any message in the log.
> An expected behavior would be the error message "Server.xml not found in the
> path [...], shutting down"
> Here are the steps to reproduce, please use GEODE-3003 for zip files.
> Test preparation:
> ---------------------
> Here are two attached zip files - "geode-host1.zip" and "geode-host2.zip"
> 1) unzip "geode-host1.zip" into some folder on your first host
> 2) in start-locator.sh change the IPs of locators to the values of your host1
> and host2
> "--locators=10.50.3.38[20236],10.50.3.14[20236]"
> 3) in start-server.sh
> "locators=10.50.3.38[20236],10.50.3.14[20236]" change the IPs of locators to
> the values of your host1 and host2
> 4) do the bullets 1)-4) for host2, the folder where you unzip the file should
> be the same as on the first host
> Test running:
> ---------------
> 0) change start-server.sh so that the path to Server.xml is wrong
> cache-xml-file=$SERVERXML_DIR/Server.xml
> ->
> cache-xml-file=$SERVERXML_DIR/Server_.xml
> 1) run ./start-locator.sh on host1
> 2) after some pause run ./start-server
> 3) observe the server started and immediately stopped,
> 4) observe in the server logs, server1/cacheserver.log:
> [info 2017/06/06 18:32:05.141 MSK host1-server-1 <main> tid=0x1] Received
> cluster configuration from the locator
> [info 2017/06/06 18:32:05.141 MSK host1-server-1 <main> tid=0x1]
> ***************************************************************
> Configuration for 'cluster'
>
> Jar files to deployed
> [info 2017/06/06 18:32:05.141 MSK host1-server-1 <main> tid=0x1] Requesting
> cluster configuration
> [info 2017/06/06 18:32:05.143 MSK host1-server-1 <main> tid=0x1] Got response
> with jars:
> [info 2017/06/06 18:32:05.209 MSK host1-server-1 <main> tid=0x1] Initializing
> region _monitoringRegion_10.50.3.38<v1>1025
> [info 2017/06/06 18:32:05.222 MSK host1-server-1 <main> tid=0x1] Region
> _monitoringRegion_10.50.3.38<v1>1025 requesting initial image from
> 10.50.3.38(host1-locator-0-20236:27511:locator)<ec><v0>:1024
> [info 2017/06/06 18:32:05.227 MSK host1-server-1 <main> tid=0x1]
> _monitoringRegion_10.50.3.38<v1>1025 is done getting image from
> 10.50.3.38(host1-locator-0-20236:27511:locator)<ec><v0>:1024. isDeltaGII is
> false
> [info 2017/06/06 18:32:05.228 MSK host1-server-1 <main> tid=0x1]
> Initialization of region _monitoringRegion_10.50.3.38<v1>1025 completed
> [info 2017/06/06 18:32:05.812 MSK host1-server-1 <main> tid=0x1]
> GemFireCache[id = 2117642238; isClosing = true; isShutDownAll = false;
> created = Tue Jun 06 18:32:05 MSK 2017; server = false; copyOnRead = false;
> lockLease = 120; lockTimeout = 60]: Now closing.
> [info 2017/06/06 18:32:05.855 MSK host1-server-1 <main> tid=0x1] Shutting
> down DistributionManager 10.50.3.38(host1-server-1:27773)<v1>:1025.
> [info 2017/06/06 18:32:05.961 MSK host1-server-1 <main> tid=0x1] Now closing
> distribution for 10.50.3.38(host1-server-1:27773)<v1>:1025
> [info 2017/06/06 18:32:05.962 MSK host1-server-1 <main> tid=0x1] Stopping
> membership services
> [info 2017/06/06 18:32:05.964 MSK host1-server-1 <Geode Failure Detection
> Server thread 0> tid=0x1d] GMSHealthMonitor server thread exiting
> [info 2017/06/06 18:32:05.964 MSK host1-server-1 <main> tid=0x1]
> GMSHealthMonitor server socket is closed in stopServices().
> [info 2017/06/06 18:32:05.968 MSK host1-server-1 <main> tid=0x1]
> GMSHealthMonitor serverSocketExecutor is terminated
> [info 2017/06/06 18:32:05.974 MSK host1-server-1 <main> tid=0x1]
> DistributionManager stopped in 119ms.
> [info 2017/06/06 18:32:05.974 MSK host1-server-1 <main> tid=0x1] Marking
> DistributionManager 10.50.3.38(host1-server-1:27773)<v1>:1025 as closed.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)