ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptupit...@apache.org
Subject ignite git commit: IGNITE-3514 C++: Fixed JVM crash on incorrect configuration
Date Fri, 16 Dec 2016 16:42:16 GMT
Repository: ignite
Updated Branches:
  refs/heads/master c530d47b8 -> a38ae7eca


IGNITE-3514 C++: Fixed JVM crash on incorrect configuration

This closes #1354


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

Branch: refs/heads/master
Commit: a38ae7eca125c6a17a468f130502de69e2aac18b
Parents: c530d47
Author: Igor Sapego <isapego@gridgain.com>
Authored: Fri Dec 16 19:42:06 2016 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Fri Dec 16 19:42:06 2016 +0300

----------------------------------------------------------------------
 .../cpp/core-test/config/cache-test.xml         |  1 +
 .../platforms/cpp/core-test/config/invalid.xml  | 39 ++++++++++++++++++++
 .../cpp/core-test/project/vs/core-test.vcxproj  |  3 +-
 .../project/vs/core-test.vcxproj.filters        |  5 ++-
 .../cpp/core-test/src/interop_test.cpp          | 17 +++++++--
 modules/platforms/cpp/core/src/ignition.cpp     | 15 ++------
 6 files changed, 64 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a38ae7ec/modules/platforms/cpp/core-test/config/cache-test.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/config/cache-test.xml b/modules/platforms/cpp/core-test/config/cache-test.xml
index 659e12d..0ea5876 100644
--- a/modules/platforms/cpp/core-test/config/cache-test.xml
+++ b/modules/platforms/cpp/core-test/config/cache-test.xml
@@ -115,6 +115,7 @@
                         </property>
                     </bean>
                 </property>
+                <property name="socketTimeout" value="300" />
             </bean>
         </property>
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/a38ae7ec/modules/platforms/cpp/core-test/config/invalid.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/config/invalid.xml b/modules/platforms/cpp/core-test/config/invalid.xml
new file mode 100644
index 0000000..d6481c7
--- /dev/null
+++ b/modules/platforms/cpp/core-test/config/invalid.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    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.
+-->
+
+<!--
+    Ignite Spring configuration file to startup grid cache.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util.xsd">
+    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="socketTimeout" value="-300" />
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/a38ae7ec/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
index c18b1c3..6f13719 100644
--- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
+++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
@@ -35,6 +35,7 @@
   <ItemGroup>
     <None Include="..\..\config\cache-query.xml" />
     <None Include="..\..\config\cache-test.xml" />
+    <None Include="..\..\config\invalid.xml" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\cache_test.cpp" />
@@ -185,4 +186,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a38ae7ec/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
index 0059364..cf1aaca 100644
--- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
+++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
@@ -88,5 +88,8 @@
     <None Include="..\..\config\cache-query.xml">
       <Filter>Configs</Filter>
     </None>
+    <None Include="..\..\config\invalid.xml">
+      <Filter>Configs</Filter>
+    </None>
   </ItemGroup>
-</Project>
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a38ae7ec/modules/platforms/cpp/core-test/src/interop_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/interop_test.cpp b/modules/platforms/cpp/core-test/src/interop_test.cpp
index 4b079d9..f29ecc8 100644
--- a/modules/platforms/cpp/core-test/src/interop_test.cpp
+++ b/modules/platforms/cpp/core-test/src/interop_test.cpp
@@ -27,7 +27,7 @@ using namespace ignite;
 using namespace cache;
 using namespace boost::unit_test;
 
-void InitConfig(IgniteConfiguration& cfg)
+void InitConfig(IgniteConfiguration& cfg, const char* config)
 {
     cfg.jvmOpts.push_back("-Xdebug");
     cfg.jvmOpts.push_back("-Xnoagent");
@@ -45,7 +45,7 @@ void InitConfig(IgniteConfiguration& cfg)
 
     char* cfgPath = getenv("IGNITE_NATIVE_TEST_CPP_CONFIG_PATH");
 
-    cfg.springCfgPath = std::string(cfgPath).append("/").append("cache-test.xml");
+    cfg.springCfgPath = std::string(cfgPath).append("/").append(config);
 }
 
 BOOST_AUTO_TEST_SUITE(InteropTestSuite)
@@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE(StringUtfValid4ByteCodePoint)
 {
     IgniteConfiguration cfg;
 
-    InitConfig(cfg);
+    InitConfig(cfg, "cache-test.xml");
 
     Ignite ignite = Ignition::Start(cfg);
 
@@ -145,4 +145,15 @@ BOOST_AUTO_TEST_CASE(StringUtfValid4ByteCodePoint)
     Ignition::StopAll(false);
 }
 
+BOOST_AUTO_TEST_CASE(GracefulDeathOnInvalidConfig)
+{
+    IgniteConfiguration cfg;
+
+    InitConfig(cfg, "invalid.xml");
+
+    BOOST_CHECK_THROW(Ignition::Start(cfg), IgniteError);
+
+    Ignition::StopAll(false);
+}
+
 BOOST_AUTO_TEST_SUITE_END()

http://git-wip-us.apache.org/repos/asf/ignite/blob/a38ae7ec/modules/platforms/cpp/core/src/ignition.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/ignition.cpp b/modules/platforms/cpp/core/src/ignition.cpp
index 72fbf7a..cd7ad70 100644
--- a/modules/platforms/cpp/core/src/ignition.cpp
+++ b/modules/platforms/cpp/core/src/ignition.cpp
@@ -282,20 +282,13 @@ namespace ignite
         factoryLock.Leave();
 
         if (failed) 
-        {
-            if (envTarget)
-                delete envTarget;
-
             return Ignite();
-        }
-        else 
-        {
-            env.Get()->ProcessorReleaseStart();
 
-            IgniteImpl* impl = new IgniteImpl(env, javaRef);
+        env.Get()->ProcessorReleaseStart();
 
-            return Ignite(impl);
-        }
+        IgniteImpl* impl = new IgniteImpl(env, javaRef);
+
+        return Ignite(impl);
     }
 
     Ignite Ignition::Get()


Mime
View raw message