diff options
author | Thomas Watson | 2016-10-31 15:49:16 +0000 |
---|---|---|
committer | Thomas Watson | 2016-11-02 20:40:22 +0000 |
commit | 49c8f08db1f396fda44605dfdcee9a924fa48a0c (patch) | |
tree | 877f46c7fca9d8246d11814f2a0d34674d1eb7fe | |
parent | 35dc5d75234efce06240f8d10e8c1f1b4b26b35b (diff) | |
download | rt.equinox.bundles-49c8f08db1f396fda44605dfdcee9a924fa48a0c.tar.gz rt.equinox.bundles-49c8f08db1f396fda44605dfdcee9a924fa48a0c.tar.xz rt.equinox.bundles-49c8f08db1f396fda44605dfdcee9a924fa48a0c.zip |
Bug 506283 - [registry] Huge amount of plugins leads to "Trouble writingY20161103-1000
Change-Id: I489188d872e0f7b7fcdd6a17f11e24d768569545
Signed-off-by: Ulf Caspers <ucaspers@hotmail.com>
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
2 files changed, 32 insertions, 12 deletions
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableReader.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableReader.java index 2e4c773a2..829d2bccb 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableReader.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableReader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,15 +23,17 @@ public class TableReader { //Markers in the cache static final int NULL = 0; static final int OBJECT = 1; + static final int LOBJECT = 2; //The version of the cache - static final int CACHE_VERSION = 7; + static final int CACHE_VERSION = 8; // Version 1 -> 2: the contributor Ids changed from "long" to "String" // Version 2 -> 3: added namespace index and the table of contributors // Version 3 -> 4: offset table saved in a binary form (performance) // Version 4 -> 5: remove support added in version 4 to save offset table in a binary form (performance) // Version 5 -> 6: replace HashtableOfInt with OffsetTable (memory usage optimization) // Version 6 -> 7: added option for multi-language support + // Version 7 -> 8: added support for large UTF-8 strings //Informations representing the MAIN file static final String MAIN = ".mainData"; //$NON-NLS-1$ @@ -63,6 +65,8 @@ public class TableReader { static final String ORPHANS = ".orphans"; //$NON-NLS-1$ File orphansFile; + static final String UTF_8 = "UTF-8"; //$NON-NLS-1$ + //Status code private static final byte fileError = 0; private static final boolean DEBUG = false; //TODO need to change @@ -152,9 +156,9 @@ public class TableReader { long contributorsFileSize = in.readLong(); long namespacesFileSize = in.readLong(); long orphansFileSize = in.readLong(); - String osStamp = readUTF(in); - String windowsStamp = readUTF(in); - String localeStamp = readUTF(in); + String osStamp = readUTF(in, OBJECT); + String windowsStamp = readUTF(in, OBJECT); + String localeStamp = readUTF(in, OBJECT); boolean multiLanguage = in.readBoolean(); boolean validTime = (expectedTimestamp == 0 || expectedTimestamp == registryStamp); @@ -380,7 +384,7 @@ public class TableReader { byte type = in.readByte(); if (type == NULL) return null; - return readUTF(in); + return readUTF(in, type); } public String[] loadExtensionExtraData(int dataPosition) { @@ -599,7 +603,7 @@ public class TableReader { int size = orphanInput.readInt(); HashMap result = new HashMap(size); for (int i = 0; i < size; i++) { - String key = readUTF(orphanInput); + String key = readUTF(orphanInput, OBJECT); int[] value = readArray(orphanInput); result.put(key, value); } @@ -646,8 +650,17 @@ public class TableReader { } } - private String readUTF(DataInputStream in) throws IOException { - String value = in.readUTF(); + private String readUTF(DataInputStream in, int type) throws IOException { + String value; + if (type == LOBJECT) { + int length = in.readInt(); + byte[] data = new byte[length]; + in.readFully(data); + value = new String(data, UTF_8); + } else { + value = in.readUTF(); + } + Map map = null; if (stringPool != null) { map = (Map) stringPool.get(); diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java index 87085e2d9..a666459ea 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -417,8 +417,15 @@ public class TableWriter { if (string == null) out.writeByte(TableReader.NULL); else { - out.writeByte(TableReader.OBJECT); - out.writeUTF(string); + byte[] data = string.getBytes(TableReader.UTF_8); + if (data.length > 65535) { + out.writeByte(TableReader.LOBJECT); + out.writeInt(data.length); + out.write(data); + } else { + out.writeByte(TableReader.OBJECT); + out.writeUTF(string); + } } } |