Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Activator.java4
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeServiceImpl.java6
-rw-r--r--bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Persistence.java10
3 files changed, 16 insertions, 4 deletions
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Activator.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Activator.java
index 446523df5..67518dc83 100644
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Activator.java
+++ b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Activator.java
@@ -231,7 +231,7 @@ public class Activator implements BundleActivator {
try {
service.load(bundleCtx, logService, mtpTracker);
} catch (IOException e) {
- logService.log(LogTracker.LOG_ERROR, "Error loading cached metatype info.", e); //$NON-NLS-1$
+ logService.log(LogTracker.LOG_WARNING, "Error loading cached metatype info.", e); //$NON-NLS-1$
}
ServiceRegistration<?> registration = bundleCtx.registerService(new String[] {MetaTypeService.class.getName(), EquinoxMetaTypeService.class.getName()}, service, properties);
synchronized (this) {
@@ -260,7 +260,7 @@ public class Activator implements BundleActivator {
try {
service.save(bundleCtx);
} catch (IOException e) {
- logService.log(LogTracker.LOG_ERROR, "Error saving metatype cache.", e); //$NON-NLS-1$
+ logService.log(LogTracker.LOG_WARNING, "Error saving metatype cache.", e); //$NON-NLS-1$
}
}
}
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeServiceImpl.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeServiceImpl.java
index a87275e3d..31f56fdb1 100644
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeServiceImpl.java
+++ b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/MetaTypeServiceImpl.java
@@ -145,7 +145,10 @@ public class MetaTypeServiceImpl implements EquinoxMetaTypeService, SynchronousB
BundleContext systemContext = context.getBundle(Constants.SYSTEM_BUNDLE_LOCATION).getBundleContext();
if (cache.isFile()) {
try (Reader reader = new Reader(new DataInputStream(new BufferedInputStream(new FileInputStream(cache))))) {
-
+ if (!reader.isValidPersistenceVersion()) {
+ logger.log(LogTracker.LOG_INFO, "Metatype cache version is not supported. Ignoring cache."); //$NON-NLS-1$
+ return;
+ }
int numService = reader.readInt();
for (int i = 0; i < numService; i++) {
long id = reader.readLong();
@@ -171,6 +174,7 @@ public class MetaTypeServiceImpl implements EquinoxMetaTypeService, SynchronousB
void save(BundleContext context) throws IOException {
File cache = context.getDataFile(CACHE_FILE);
try (Writer writer = new Writer(new DataOutputStream(new BufferedOutputStream(new FileOutputStream(cache))))) {
+ writer.writePersistenceVersion();
List<MetaTypeInformation> serviceInfos = new ArrayList<>();
List<MetaTypeInformationImpl> xmlInfos = new ArrayList<>();
synchronized (_mtps) {
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Persistence.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Persistence.java
index da3212b10..a0e6ea2fb 100644
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Persistence.java
+++ b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Persistence.java
@@ -18,7 +18,7 @@ import java.util.*;
*******************************************************************************/
public class Persistence {
-
+ private static final int PERSISTENCE_VERSION = 0;
private static final String UTF_8 = "UTF-8"; //$NON-NLS-1$
private static final byte NULL = 0;
private static final byte OBJECT = 1;
@@ -36,6 +36,10 @@ public class Persistence {
this.in = in;
}
+ public boolean isValidPersistenceVersion() throws IOException {
+ return in.readInt() == PERSISTENCE_VERSION;
+ }
+
public void readIndexedStrings() throws IOException {
int num = in.readInt();
for (int i = 0; i < num; i++) {
@@ -117,6 +121,10 @@ public class Persistence {
this.out = out;
}
+ public void writePersistenceVersion() throws IOException {
+ out.writeInt(PERSISTENCE_VERSION);
+ }
+
public void writeIndexedStrings(Set<String> strings) throws IOException {
strings.remove(null); // do not index null
out.writeInt(strings.size());

Back to the top