Skip to content

Commit

Permalink
GEODE-9346: When client received incorrect byte array of PdxType due … (
Browse files Browse the repository at this point in the history
  • Loading branch information
gesterzhou authored Jul 9, 2021
1 parent 6ba9a82 commit 11e4c3a
Show file tree
Hide file tree
Showing 5 changed files with 442 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.geode.LogWriter;
import org.apache.geode.cache.AttributesFactory;
Expand Down Expand Up @@ -82,7 +83,7 @@ public final void preTearDownCacheTestCase() throws Exception {
preTearDownPDXQueryTestBase();
disconnectAllFromDS(); // tests all expect to create a new ds
// Reset the testObject numinstance for the next test.
TestObject.numInstance = 0;
TestObject.numInstance.set(0);
// In all VM.
resetTestObjectInstanceCount();
}
Expand All @@ -96,11 +97,11 @@ private void resetTestObjectInstanceCount() {
vm.invoke(new CacheSerializableRunnable("Create cache server") {
@Override
public void run2() throws CacheException {
TestObject.numInstance = 0;
TestObject.numInstance.set(0);
PortfolioPdx.numInstance = 0;
PositionPdx.numInstance = 0;
PositionPdx.cnt = 0;
TestObject2.numInstance = 0;
TestObject2.numInstance.set(0);
}
});
}
Expand Down Expand Up @@ -306,15 +307,15 @@ protected void startCacheServer(int port, boolean notifyBySubscription) throws I

public static class TestObject2 implements PdxSerializable {
public int _id;
public static int numInstance = 0;
public static AtomicInteger numInstance = new AtomicInteger();

public TestObject2() {
numInstance++;
numInstance.incrementAndGet();
}

public TestObject2(int id) {
this._id = id;
numInstance++;
numInstance.incrementAndGet();
}

public int getId() {
Expand Down Expand Up @@ -359,7 +360,7 @@ public static class TestObject implements PdxSerializable {
public int important;
public int selection;
public int select;
public static int numInstance = 0;
public static final AtomicInteger numInstance = new AtomicInteger();
public Map idTickers = new HashMap();
public HashMap positions = new HashMap();
public TestObject2 test;
Expand All @@ -368,7 +369,7 @@ public TestObject() {
if (log != null) {
log.info("TestObject ctor stack trace", new Exception());
}
numInstance++;
numInstance.incrementAndGet();
}

public TestObject(int id, String ticker) {
Expand All @@ -381,7 +382,7 @@ public TestObject(int id, String ticker) {
this.important = id;
this.selection = id;
this.select = id;
numInstance++;
numInstance.incrementAndGet();
idTickers.put(id + "", ticker);
this.test = new TestObject2(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ public void run2() throws CacheException {
protected final void preTearDownPDXQueryTestBase() throws Exception {
disconnectAllFromDS(); // tests all expect to create a new ds
// Reset the testObject numinstance for the next test.
TestObject.numInstance = 0;
TestObject.numInstance.set(0);
PortfolioPdx.DEBUG = false;
// In all VM.
resetTestObjectInstanceCount();
Expand All @@ -917,11 +917,11 @@ private void resetTestObjectInstanceCount() {
vm.invoke(new CacheSerializableRunnable("Create cache server") {
@Override
public void run2() throws CacheException {
TestObject.numInstance = 0;
TestObject.numInstance.set(0);
PortfolioPdx.numInstance = 0;
PositionPdx.numInstance = 0;
PositionPdx.cnt = 0;
TestObject2.numInstance = 0;
TestObject2.numInstance.set(0);
}
});
}
Expand Down
Loading

0 comments on commit 11e4c3a

Please sign in to comment.