You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sh...@apache.org on 2016/11/07 04:30:27 UTC
[40/50] [abbrv] ignite git commit: ignite-3722 Cached in a file text
must be written with UTF-8 charset, not default. This closes #1144.
ignite-3722 Cached in a file text must be written with UTF-8 charset, not default. This closes #1144.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5afd6546
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5afd6546
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5afd6546
Branch: refs/heads/ignite-2788
Commit: 5afd6546f6ed650ad0db8d7ce83944188902b805
Parents: 3271d75
Author: Saikat Maitra <sa...@gmail.com>
Authored: Thu Oct 6 08:42:45 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Oct 6 08:42:45 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/MarshallerContextImpl.java | 7 +-
.../marshaller/MarshallerContextSelfTest.java | 90 ++++++++++++++++++++
.../ignite/testsuites/IgniteBasicTestSuite.java | 2 +
3 files changed, 96 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5afd6546/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
index 0420e18..5f1622d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
@@ -28,6 +28,7 @@ import java.io.Writer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.nio.channels.OverlappingFileLockException;
+import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadLocalRandom;
@@ -179,7 +180,7 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
}
/** {@inheritDoc} */
- @Override protected String className(int id) throws IgniteCheckedException {
+ @Override public String className(int id) throws IgniteCheckedException {
GridCacheAdapter<Integer, String> cache0 = cache;
if (cache0 == null) {
@@ -208,7 +209,7 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
assert fileLock != null : fileName;
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) {
clsName = reader.readLine();
}
}
@@ -297,7 +298,7 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
assert fileLock != null : fileName;
- try (Writer writer = new OutputStreamWriter(out)) {
+ try (Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8)) {
writer.write(evt.getValue());
writer.flush();
http://git-wip-us.apache.org/repos/asf/ignite/blob/5afd6546/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextSelfTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextSelfTest.java
new file mode 100644
index 0000000..f61a2aa
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextSelfTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.ignite.marshaller;
+
+import java.io.File;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import javax.cache.event.EventType;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.MarshallerContextImpl;
+import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static java.nio.file.Files.readAllBytes;
+
+/**
+ * Test marshaller context.
+ */
+public class MarshallerContextSelfTest extends GridCommonAbstractTest {
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClassName() throws Exception {
+ File workDir = U.resolveWorkDirectory("marshaller", false);
+
+ final MarshallerContextImpl.ContinuousQueryListener queryListener =
+ new MarshallerContextImpl.ContinuousQueryListener(log, workDir);
+
+ final ArrayList evts = new ArrayList<>();
+
+ IgniteCacheProxy cache = new IgniteCacheProxy();
+
+ evts.add(new CacheContinuousQueryManager.CacheEntryEventImpl(cache,
+ EventType.CREATED,
+ 1,
+ String.class.getName()));
+
+ queryListener.onUpdated(evts);
+
+ try (Ignite g1 = startGrid(1)) {
+ MarshallerContextImpl marshCtx = ((IgniteKernal)g1).context().marshallerContext();
+ String clsName = marshCtx.className(1);
+
+ assertEquals("java.lang.String", clsName);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOnUpdated() throws Exception {
+ File workDir = U.resolveWorkDirectory("marshaller", false);
+
+ final MarshallerContextImpl.ContinuousQueryListener queryListener =
+ new MarshallerContextImpl.ContinuousQueryListener(log, workDir);
+
+ final ArrayList evts = new ArrayList<>();
+
+ IgniteCacheProxy cache = new IgniteCacheProxy();
+
+ evts.add(new CacheContinuousQueryManager.CacheEntryEventImpl(cache,
+ EventType.CREATED,
+ 1,
+ String.class.getName()));
+
+ queryListener.onUpdated(evts);
+
+ String fileName = "1.classname";
+
+ assertEquals("java.lang.String", new String(readAllBytes(Paths.get(workDir + "/" + fileName))));
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5afd6546/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index 2717b06..3dca5e1 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -51,6 +51,7 @@ import org.apache.ignite.internal.product.GridProductVersionSelfTest;
import org.apache.ignite.internal.util.nio.IgniteExceptionInNioWorkerSelfTest;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.DynamicProxySerializationMultiJvmSelfTest;
+import org.apache.ignite.marshaller.MarshallerContextSelfTest;
import org.apache.ignite.messaging.GridMessagingNoPeerClassLoadingSelfTest;
import org.apache.ignite.messaging.GridMessagingSelfTest;
import org.apache.ignite.messaging.IgniteMessagingWithClientTest;
@@ -143,6 +144,7 @@ public class IgniteBasicTestSuite extends TestSuite {
suite.addTestSuite(NotStringSystemPropertyTest.class);
suite.addTestSuite(MarshallerContextLockingSelfTest.class);
+ suite.addTestSuite(MarshallerContextSelfTest.class);
return suite;
}