Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 94E8917F25 for ; Mon, 8 Jun 2015 09:59:55 +0000 (UTC) Received: (qmail 84198 invoked by uid 500); 8 Jun 2015 09:59:55 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 84169 invoked by uid 500); 8 Jun 2015 09:59:55 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 84155 invoked by uid 99); 8 Jun 2015 09:59:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Jun 2015 09:59:55 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 08 Jun 2015 09:57:34 +0000 Received: (qmail 83239 invoked by uid 99); 8 Jun 2015 09:59:21 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Jun 2015 09:59:21 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7D4EBDFF60; Mon, 8 Jun 2015 09:59:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Date: Mon, 08 Jun 2015 09:59:36 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [16/17] incubator-ignite git commit: # ignite-sprint-5 sanity check for classname.properies load X-Virus-Checked: Checked by ClamAV on apache.org # ignite-sprint-5 sanity check for classname.properies load Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/8467a3c3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/8467a3c3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/8467a3c3 Branch: refs/heads/ignite-gg-10299 Commit: 8467a3c36414192268b8d852715fc501f53b4772 Parents: a5b5ec7 Author: sboikov Authored: Mon Jun 8 12:42:36 2015 +0300 Committer: sboikov Committed: Mon Jun 8 12:42:36 2015 +0300 ---------------------------------------------------------------------- .../internal/MarshallerContextAdapter.java | 36 ++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8467a3c3/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java index 5dca2f2..21f2264 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal; import org.apache.ignite.*; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.marshaller.*; import org.jsr166.*; @@ -49,10 +50,29 @@ public abstract class MarshallerContextAdapter implements MarshallerContext { Enumeration urls = ldr.getResources(CLS_NAMES_FILE); - while (urls.hasMoreElements()) + boolean foundClsNames = false; + + while (urls.hasMoreElements()) { processResource(urls.nextElement()); - processResource(ldr.getResource(JDK_CLS_NAMES_FILE)); + foundClsNames = true; + } + + if (!foundClsNames) + throw new IgniteException("Failed to load class names properties file packaged with ignite binaries " + + "[file=" + CLS_NAMES_FILE + ", ldr=" + ldr + ']'); + + URL jdkClsNames = ldr.getResource(JDK_CLS_NAMES_FILE); + + if (jdkClsNames == null) + throw new IgniteException("Failed to load class names properties file packaged with ignite binaries " + + "[file=" + JDK_CLS_NAMES_FILE + ", ldr=" + ldr + ']'); + + processResource(jdkClsNames); + + checkHasClassName(GridDhtPartitionFullMap.class.getName(), ldr, CLS_NAMES_FILE); + checkHasClassName(GridDhtPartitionMap.class.getName(), ldr, CLS_NAMES_FILE); + checkHasClassName(HashMap.class.getName(), ldr, JDK_CLS_NAMES_FILE); } catch (IOException e) { throw new IllegalStateException("Failed to initialize marshaller context.", e); @@ -60,6 +80,18 @@ public abstract class MarshallerContextAdapter implements MarshallerContext { } /** + * @param clsName Class name. + * @param ldr Class loader used to get properties file. + * @param fileName File name. + */ + private void checkHasClassName(String clsName, ClassLoader ldr, String fileName) { + if (!map.containsKey(clsName.hashCode())) + throw new IgniteException("Failed to read class name from class names properties file. " + + "Make sure class names properties file packaged with ignite binaries is not corrupted " + + "[clsName=" + clsName + ", fileName=" + fileName + ", ldr=" + ldr + ']'); + } + + /** * @param url Resource URL. * @throws IOException In case of error. */