[Joafip-svn] SF.net SVN: joafip:[2912] trunk/joafip/src
Brought to you by:
luc_peuvrier
|
From: <luc...@us...> - 2011-10-02 08:33:41
|
Revision: 2912
http://joafip.svn.sourceforge.net/joafip/?rev=2912&view=rev
Author: luc_peuvrier
Date: 2011-10-02 08:33:34 +0000 (Sun, 02 Oct 2011)
Log Message:
-----------
problems with static field modified when persisted
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/entity/StoreSynchro.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java
Added Paths:
-----------
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticField.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticFieldMap.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSaveWithStatic.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/StoreSynchro.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/StoreSynchro.java 2011-10-01 17:08:48 UTC (rev 2911)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/StoreSynchro.java 2011-10-02 08:33:34 UTC (rev 2912)
@@ -42,6 +42,8 @@
public StoreSynchro() { // NOPMD
super();
+ // FIXMELUC _____________________for test
+ Thread.dumpStack();
}
public void setPersistenceId(final int persistenceId) {
@@ -60,7 +62,6 @@
/* a not valid identifier value when access session is closed */
fileAccessSessionIdentifier = -1;
}
-
return persistenceId | fileAccessSessionIdentifier;
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java 2011-10-01 17:08:48 UTC (rev 2911)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java 2011-10-02 08:33:34 UTC (rev 2912)
@@ -425,8 +425,9 @@
queueSize = 0;
queueNumberOfWeakRef = 0;
}
- // static persistence information live with file persistence
- // staticStateMap.clear();
+ // FIXMELUC ____________________static persistence information live
+ // with file persistence
+ staticStateMap.clear();
// checkNullFieldError();
}
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java 2011-10-01 17:08:48 UTC (rev 2911)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java 2011-10-02 08:33:34 UTC (rev 2912)
@@ -1248,8 +1248,8 @@
objectAndPersistInfo
.setDataRecordIdentifier(dataRecordIdentifier);
objectAndPersistInfo.setReplacementDefList(replacementDef);
- objectInputStatic.setObjectState(objectAndPersistInfo, binary,
- offset);
+ objectInputStatic.setObjectStaticState(objectAndPersistInfo,
+ binary, offset);
// not a new object to add to storage, created reading in
// storage
objectAndPersistInfo.setNewObject(false);
Added: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticField.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticField.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticField.java 2011-10-02 08:33:34 UTC (rev 2912)
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * 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 net.sf.joafip.service.rel400;
+
+import java.util.Map;
+
+import net.sf.joafip.StorableClass;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@StorableClass
+public class PersistableWithStaticField {
+
+ private static final PersistableWithStaticField EMPTY = new PersistableWithStaticField(
+ "");
+
+ private static Map<String, PersistableWithStaticField> map;
+
+ static {
+ map = new PersistableWithStaticFieldMap();
+ map.put(EMPTY.getKey(), EMPTY);
+ }
+
+ private final String key;
+
+ public PersistableWithStaticField(final String key) {
+ super();
+ this.key = key;
+ }
+
+ public String getKey() {
+ return key;
+ }
+}
Added: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticFieldMap.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticFieldMap.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/PersistableWithStaticFieldMap.java 2011-10-02 08:33:34 UTC (rev 2912)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * 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 net.sf.joafip.service.rel400;
+
+import net.sf.joafip.StorableClass;
+import net.sf.joafip.StoreNotUseStandardSerialization;
+import net.sf.joafip.java.util.PTreeMap;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@StoreNotUseStandardSerialization
+@StorableClass
+public class PersistableWithStaticFieldMap extends
+ PTreeMap<String, PersistableWithStaticField> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4317793725458311008L;
+
+}
Added: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSaveWithStatic.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSaveWithStatic.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSaveWithStatic.java 2011-10-02 08:33:34 UTC (rev 2912)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * 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 net.sf.joafip.service.rel400;
+
+import net.sf.joafip.AbstractDeleteFileTestCase;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.TestException;
+import net.sf.joafip.service.FilePersistenceBuilder;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.service.IExclusiveDataAccessSession;
+import net.sf.joafip.service.IFilePersistence;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@StorableAccess
+public class TestAutoSaveWithStatic extends AbstractDeleteFileTestCase {
+
+ public TestAutoSaveWithStatic() throws TestException {
+ super();
+ }
+
+ public TestAutoSaveWithStatic(final String name) throws TestException {
+ super(name);
+ }
+
+ @SuppressWarnings("PMD")
+ public void test() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException {
+ createFilePersistence();
+ // second failed before correction
+ createFilePersistence();
+ }
+
+ private void createFilePersistence() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ builder.setPathName(path.getAbsolutePath());
+ builder.setProxyMode(true);
+ builder.setRemoveFiles(true);
+ final IFilePersistence filePersistence = builder.build();
+ filePersistence.storedStaticField(PersistableWithStaticField.class);
+ final IExclusiveDataAccessSession session = filePersistence
+ .createExclusiveDataAccessSession();
+ session.open();
+ session.close();
+ filePersistence.close();
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|