1.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/indexing/Cache.java Thu Dec 16 23:09:00 2010 +0100
1.2 +++ b/api/src/org/netbeans/modules/jackpot30/impl/indexing/Cache.java Fri Dec 17 21:18:14 2010 +0100
1.3 @@ -113,6 +113,7 @@
1.4
1.5
1.6 private static Properties segments;
1.7 + private static long lastSegmentsTimeStamp = -1;
1.8 private static Map<String, String> invertedSegments;
1.9 private static int index = 0;
1.10
1.11 @@ -120,12 +121,18 @@
1.12 private static final String SLICE_PREFIX = "s"; //NOI18N
1.13
1.14 private static void loadSegments () throws IOException {
1.15 + final File folder = standaloneCacheRoot;
1.16 + assert folder != null;
1.17 + final File segmentsFile = new File(folder, SEGMENTS_FILE);
1.18 +
1.19 + if (lastSegmentsTimeStamp != segmentsFile.lastModified()) {
1.20 + lastSegmentsTimeStamp = segmentsFile.lastModified();
1.21 + segments = null;
1.22 + }
1.23 +
1.24 if (segments == null) {
1.25 - final File folder = standaloneCacheRoot;
1.26 - assert folder != null;
1.27 segments = new Properties ();
1.28 invertedSegments = new HashMap<String,String> ();
1.29 - final File segmentsFile = new File(folder, SEGMENTS_FILE);
1.30 if (segmentsFile.canRead()) {
1.31 final InputStream in = new FileInputStream(segmentsFile);
1.32 try {
1.33 @@ -147,7 +154,7 @@
1.34 }
1.35 }
1.36
1.37 - public static Iterable<? extends String> knownSourceRoots() throws IOException {
1.38 + public static synchronized Iterable<? extends String> knownSourceRoots() throws IOException {
1.39 loadSegments();
1.40
1.41 List<String> known = new LinkedList<String>();
1.42 @@ -159,7 +166,7 @@
1.43 return known;
1.44 }
1.45
1.46 - public static File sourceRootForKey(String segment) throws IOException {
1.47 + public static synchronized File sourceRootForKey(String segment) throws IOException {
1.48 loadSegments();
1.49
1.50 try {
2.1 --- a/server/hudson/src/main/java/org/netbeans/modules/jackpot30/hudson/Cache.java Thu Dec 16 23:09:00 2010 +0100
2.2 +++ b/server/hudson/src/main/java/org/netbeans/modules/jackpot30/hudson/Cache.java Fri Dec 17 21:18:14 2010 +0100
2.3 @@ -102,6 +102,7 @@
2.4
2.5
2.6 private static Properties segments;
2.7 + private static long lastSegmentsTimeStamp = -1;
2.8 private static Map<String, String> invertedSegments;
2.9 private static int index = 0;
2.10
2.11 @@ -109,12 +110,18 @@
2.12 private static final String SLICE_PREFIX = "s"; //NOI18N
2.13
2.14 private static void loadSegments () throws IOException {
2.15 + final File folder = standaloneCacheRoot;
2.16 + assert folder != null;
2.17 + final File segmentsFile = new File(folder, SEGMENTS_FILE);
2.18 +
2.19 + if (lastSegmentsTimeStamp != segmentsFile.lastModified()) {
2.20 + lastSegmentsTimeStamp = segmentsFile.lastModified();
2.21 + segments = null;
2.22 + }
2.23 +
2.24 if (segments == null) {
2.25 - final File folder = standaloneCacheRoot;
2.26 - assert folder != null;
2.27 segments = new Properties ();
2.28 invertedSegments = new HashMap<String,String> ();
2.29 - final File segmentsFile = new File(folder, SEGMENTS_FILE);
2.30 if (segmentsFile.canRead()) {
2.31 final InputStream in = new FileInputStream(segmentsFile);
2.32 try {
2.33 @@ -136,7 +143,7 @@
2.34 }
2.35 }
2.36
2.37 - public static Iterable<? extends String> knownSourceRoots() throws IOException {
2.38 + public static synchronized Iterable<? extends String> knownSourceRoots() throws IOException {
2.39 loadSegments();
2.40
2.41 List<String> known = new LinkedList<String>();
2.42 @@ -148,7 +155,7 @@
2.43 return known;
2.44 }
2.45
2.46 - public static File sourceRootForKey(String segment) throws IOException {
2.47 + public static synchronized File sourceRootForKey(String segment) throws IOException {
2.48 loadSegments();
2.49
2.50 try {