This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 199808
Collapse All | Expand All

(-)a/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java (-1 / +6 lines)
Lines 4254-4260 Link Here
4254
4254
4255
    } // End of TestIndexFactoryImpl class
4255
    } // End of TestIndexFactoryImpl class
4256
4256
4257
    private static final class TestIndexImpl implements DocumentIndex {
4257
    private static final class TestIndexImpl implements DocumentIndex.DocumentIndexWithStatus {
4258
4258
4259
        public TestIndexImpl(DocumentIndex original) {
4259
        public TestIndexImpl(DocumentIndex original) {
4260
            this.original = original;
4260
            this.original = original;
Lines 4265-4270 Link Here
4265
            return Status.VALID;
4265
            return Status.VALID;
4266
        }
4266
        }
4267
4267
4268
        @Override
4269
        public boolean isValid() throws IOException {
4270
            return true;
4271
        }
4272
4268
        // --------------------------------------------------------------------
4273
        // --------------------------------------------------------------------
4269
        // IndexImpl implementation
4274
        // IndexImpl implementation
4270
        // --------------------------------------------------------------------
4275
        // --------------------------------------------------------------------
(-)a/java.source/nbproject/project.properties (-1 / +1 lines)
Lines 46-52 Link Here
46
javadoc.title=Java Source
46
javadoc.title=Java Source
47
javadoc.arch=${basedir}/arch.xml
47
javadoc.arch=${basedir}/arch.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
49
spec.version.base=0.79.1
49
spec.version.base=0.80.1
50
test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/javac-api-nb-7.0-b07.jar
50
test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/javac-api-nb-7.0-b07.jar
51
test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\
51
test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\
52
    ${o.n.core.dir}/lib/boot.jar:\
52
    ${o.n.core.dir}/lib/boot.jar:\
(-)a/java.source/nbproject/project.xml (-2 / +1 lines)
Lines 257-264 Link Here
257
                    <build-prerequisite/>
257
                    <build-prerequisite/>
258
                    <compile-dependency/>
258
                    <compile-dependency/>
259
                    <run-dependency>
259
                    <run-dependency>
260
                        <release-version>2</release-version>
260
                        <specification-version>1.5.1</specification-version>
261
                        <specification-version>2.2.1</specification-version>
262
                    </run-dependency>
261
                    </run-dependency>
263
                </dependency>
262
                </dependency>
264
                <dependency>
263
                <dependency>
(-)a/java.source/src/org/netbeans/modules/java/source/usages/PersistentClassIndex.java (-2 / +11 lines)
Lines 127-133 Link Here
127
            return IndexManager.readAccess(new IndexManager.Action<Boolean>() {
127
            return IndexManager.readAccess(new IndexManager.Action<Boolean>() {
128
                @Override
128
                @Override
129
                public Boolean run() throws IOException, InterruptedException {
129
                public Boolean run() throws IOException, InterruptedException {
130
                    return index.getStatus(false) == Index.Status.EMPTY;
130
                    if (index instanceof Index.IndexWithStatus) {
131
                        //Fast path
132
                        return ((Index.IndexWithStatus)index).getStatus(false) == Index.Status.EMPTY;
133
                    } else {
134
                       return !index.exists();
135
                    }
131
                }
136
                }
132
            }).booleanValue();
137
            }).booleanValue();
133
        } catch (InterruptedException ie) {
138
        } catch (InterruptedException ie) {
Lines 142-148 Link Here
142
    @Override
147
    @Override
143
    public boolean isValid() {
148
    public boolean isValid() {
144
        try {
149
        try {
145
            return index.getStatus(true) != Index.Status.INVALID;
150
            if (index instanceof Index.IndexWithStatus) {
151
                return ((Index.IndexWithStatus)index).getStatus(true) != Index.Status.INVALID;
152
            } else {
153
                return index.isValid(true);
154
            }
146
        } catch (IOException ex) {
155
        } catch (IOException ex) {
147
            return false;
156
            return false;
148
        }
157
        }
(-)a/java.source/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java (-2 / +12 lines)
Lines 2186-2192 Link Here
2186
2186
2187
    }
2187
    }
2188
2188
2189
    private static class TestIndex implements Index {
2189
    private static class TestIndex implements Index.IndexWithStatus {
2190
        //Activate the TestIndex.await after scan is done
2190
        //Activate the TestIndex.await after scan is done
2191
        //during the scan the prebuildArgs may call the index
2191
        //during the scan the prebuildArgs may call the index
2192
        //and cause deadlock
2192
        //and cause deadlock
Lines 2200-2206 Link Here
2200
        public Status getStatus(boolean tryOpen) throws IOException {
2200
        public Status getStatus(boolean tryOpen) throws IOException {
2201
            return Status.VALID;
2201
            return Status.VALID;
2202
        }
2202
        }
2203
        
2203
2204
        @Override
2205
        public boolean exists() {
2206
            return true;
2207
        }
2208
2209
        @Override
2210
        public boolean isValid(boolean tryOpen) throws IOException {
2211
            return true;
2212
        }
2213
2204
        @Override
2214
        @Override
2205
        public <T> void query(
2215
        public <T> void query(
2206
                Collection<? super T> result,
2216
                Collection<? super T> result,
(-)a/java.sourceui/nbproject/project.properties (-1 / +1 lines)
Lines 2-5 Link Here
2
javac.compilerargs=-Xlint -Xlint:-serial
2
javac.compilerargs=-Xlint -Xlint:-serial
3
javac.source=1.6
3
javac.source=1.6
4
javadoc.arch=${basedir}/arch.xml
4
javadoc.arch=${basedir}/arch.xml
5
spec.version.base=1.22.1
5
spec.version.base=1.23.1
(-)a/java.sourceui/nbproject/project.xml (-2 / +1 lines)
Lines 124-131 Link Here
124
                    <build-prerequisite/>
124
                    <build-prerequisite/>
125
                    <compile-dependency/>
125
                    <compile-dependency/>
126
                    <run-dependency>
126
                    <run-dependency>
127
                        <release-version>2</release-version>
127
                        <specification-version>1.5.1</specification-version>
128
                        <specification-version>2.2.1</specification-version>
129
                    </run-dependency>
128
                    </run-dependency>
130
                </dependency>
129
                </dependency>
131
                <dependency>
130
                <dependency>
(-)a/parsing.api/nbproject/project.properties (-1 / +1 lines)
Lines 2-5 Link Here
2
javac.source=1.6
2
javac.source=1.6
3
javadoc.apichanges=${basedir}/apichanges.xml
3
javadoc.apichanges=${basedir}/apichanges.xml
4
javadoc.arch=${basedir}/arch.xml
4
javadoc.arch=${basedir}/arch.xml
5
spec.version.base=1.42.1
5
spec.version.base=1.43.1
(-)a/parsing.api/nbproject/project.xml (-2 / +1 lines)
Lines 109-116 Link Here
109
                    <build-prerequisite/>
109
                    <build-prerequisite/>
110
                    <compile-dependency/>
110
                    <compile-dependency/>
111
                    <run-dependency>
111
                    <run-dependency>
112
                        <release-version>2</release-version>
112
                        <specification-version>1.5.1</specification-version>
113
                        <specification-version>2.2.1</specification-version>
114
                    </run-dependency>
113
                    </run-dependency>
115
                </dependency>
114
                </dependency>
116
                <dependency>
115
                <dependency>
(-)a/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/support/IndexingSupport.java (-1 / +6 lines)
Lines 47-52 Link Here
47
import org.netbeans.modules.parsing.impl.indexing.FileObjectIndexable;
47
import org.netbeans.modules.parsing.impl.indexing.FileObjectIndexable;
48
import org.netbeans.modules.parsing.impl.indexing.IndexFactoryImpl;
48
import org.netbeans.modules.parsing.impl.indexing.IndexFactoryImpl;
49
import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
49
import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
50
import org.netbeans.modules.parsing.lucene.support.DocumentIndex;
50
import org.netbeans.modules.parsing.lucene.support.Index;
51
import org.netbeans.modules.parsing.lucene.support.Index;
51
import org.netbeans.modules.parsing.spi.indexing.Context;
52
import org.netbeans.modules.parsing.spi.indexing.Context;
52
import org.netbeans.modules.parsing.spi.indexing.Indexable;
53
import org.netbeans.modules.parsing.spi.indexing.Indexable;
Lines 107-113 Link Here
107
     */
108
     */
108
    public boolean isValid() {
109
    public boolean isValid() {
109
        try {
110
        try {
110
            return spiIndex.getStatus() != Index.Status.INVALID;
111
            if (spiIndex instanceof DocumentIndex.DocumentIndexWithStatus) {
112
                return ((DocumentIndex.DocumentIndexWithStatus)spiIndex).getStatus() != Index.Status.INVALID;
113
            } else {
114
                return spiIndex.isValid();
115
            }
111
        } catch (IOException e) {
116
        } catch (IOException e) {
112
            return false;
117
            return false;
113
        }
118
        }
(-)a/parsing.lucene/manifest.mf (-2 / +2 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
AutoUpdate-Show-In-Client: false
2
AutoUpdate-Show-In-Client: false
3
OpenIDE-Module: org.netbeans.modules.parsing.lucene/2
3
OpenIDE-Module: org.netbeans.modules.parsing.lucene
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/parsing/lucene/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/parsing/lucene/Bundle.properties
5
OpenIDE-Module-Specification-Version: 2.2.1
5
OpenIDE-Module-Specification-Version: 1.5.1
6
6
(-)a/parsing.lucene/src/org/netbeans/modules/parsing/lucene/DocumentIndexImpl.java (-3 / +16 lines)
Lines 67-73 Link Here
67
 *
67
 *
68
 * @author Tomas Zezula
68
 * @author Tomas Zezula
69
 */
69
 */
70
public final class DocumentIndexImpl implements DocumentIndex {
70
public final class DocumentIndexImpl implements DocumentIndex.DocumentIndexWithStatus {
71
    
71
    
72
    private final Index luceneIndex;
72
    private final Index luceneIndex;
73
    private static final Convertor<IndexDocumentImpl,Document> ADD_CONVERTOR = new AddConvertor();
73
    private static final Convertor<IndexDocumentImpl,Document> ADD_CONVERTOR = new AddConvertor();
Lines 148-156 Link Here
148
     */
148
     */
149
    @Override
149
    @Override
150
    public Index.Status getStatus() throws IOException {
150
    public Index.Status getStatus() throws IOException {
151
        return luceneIndex.getStatus(true);
151
        if (luceneIndex instanceof Index.IndexWithStatus) {
152
            return ((Index.IndexWithStatus)luceneIndex).getStatus(true);
153
        } else if (luceneIndex.isValid(true)) {
154
            return Index.Status.VALID;
155
        } else if (!luceneIndex.exists()) {
156
            return Index.Status.EMPTY;
157
        } else {
158
            return Index.Status.INVALID;
159
        }
152
    }
160
    }
153
    
161
162
    @Override
163
    public boolean isValid() throws IOException {
164
        return luceneIndex.isValid(true);
165
    }
166
154
    @Override
167
    @Override
155
    public void close() throws IOException {
168
    public void close() throws IOException {
156
        luceneIndex.close();
169
        luceneIndex.close();
(-)a/parsing.lucene/src/org/netbeans/modules/parsing/lucene/LuceneIndex.java (-1 / +11 lines)
Lines 100-106 Link Here
100
 * @author Tomas Zezula
100
 * @author Tomas Zezula
101
 */
101
 */
102
//@NotTreadSafe
102
//@NotTreadSafe
103
public class LuceneIndex implements Index {
103
public class LuceneIndex implements Index.IndexWithStatus {
104
104
105
    private static final String PROP_INDEX_POLICY = "java.index.useMemCache";   //NOI18N
105
    private static final String PROP_INDEX_POLICY = "java.index.useMemCache";   //NOI18N
106
    private static final String PROP_CACHE_SIZE = "java.index.size";    //NOI18N
106
    private static final String PROP_CACHE_SIZE = "java.index.size";    //NOI18N
Lines 375-380 Link Here
375
    }
375
    }
376
376
377
    @Override
377
    @Override
378
    public boolean exists() {
379
        return this.dirCache.exists();
380
    }
381
382
    @Override
383
    public boolean isValid(boolean tryOpen) throws IOException {
384
        return dirCache.getStatus(tryOpen) == Index.Status.VALID;
385
    }
386
387
    @Override
378
    public void clear () throws IOException {
388
    public void clear () throws IOException {
379
        try {
389
        try {
380
            IndexManager.writeAccess(new IndexManager.Action<Void>() {
390
            IndexManager.writeAccess(new IndexManager.Action<Void>() {
(-)a/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/DocumentIndex.java (-6 / +16 lines)
Lines 54-60 Link Here
54
 * @author Tomas Zezula
54
 * @author Tomas Zezula
55
 */
55
 */
56
public interface DocumentIndex {
56
public interface DocumentIndex {
57
    
57
58
    public static interface DocumentIndexWithStatus extends DocumentIndex {
59
       /**
60
        * Checks the validity of the index, see {@link Index#isValid(boolean)} for details
61
        * Checks the validity of the index, see {@link Index#getStatus(boolean)} for details
62
        * @return {@link Status#INVALID} when the index is broken, {@link Status#EMPTY}
63
        * when the index does not exist or {@link  Status#VALID} if the index is valid
64
        * @throws IOException in case of IO error
65
        * @since 1.5
66
        */
67
        public Index.Status getStatus() throws IOException;
68
    }
69
58
    /**
70
    /**
59
     * Adds a document into the index.
71
     * Adds a document into the index.
60
     * The document may not be added persistently until {@link DocumentIndex#store(boolean)} is called
72
     * The document may not be added persistently until {@link DocumentIndex#store(boolean)} is called
Lines 69-81 Link Here
69
    void removeDocument (@NonNull String primaryKey);
81
    void removeDocument (@NonNull String primaryKey);
70
82
71
    /**
83
    /**
72
     * Checks the validity of the index, see {@link Index#getStatus(boolean)} for details
84
     * Checks the validity of the index, see {@link Index#isValid(boolean)} for details
73
     * @return {@link Status#INVALID} when the index is broken, {@link Status#EMPTY}
85
     * @return true if index exists and is not broken
74
     * when the index does not exist or {@link  Status#VALID} if the index is valid
75
     * @throws IOException in case of IO error
86
     * @throws IOException in case of IO error
76
     * @since 2.1
77
     */
87
     */
78
    public Index.Status getStatus() throws IOException;
88
    public boolean isValid() throws IOException;
79
    
89
    
80
    /**
90
    /**
81
     * Closes the index.
91
     * Closes the index.
(-)a/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/Index.java (-7 / +22 lines)
Lines 65-71 Link Here
65
65
66
    /**
66
    /**
67
     * Index status returned by {@link Index#getStatus(boolean)} method
67
     * Index status returned by {@link Index#getStatus(boolean)} method
68
     * @since 2.1
68
     * @since 1.5
69
     */
69
     */
70
    enum Status {
70
    enum Status {
71
        /**
71
        /**
Lines 81-104 Link Here
81
         */
81
         */
82
        VALID;
82
        VALID;
83
    }
83
    }
84
    
84
85
    public static interface IndexWithStatus extends Index {
86
        /**
87
        * Checks the validity of the index. The index is invalid when it's broken.
88
        * @param tryOpen when true the {@link Index} does exact but more expensive check.
89
        * @return {@link Status#INVALID} when the index is broken, {@link Status#EMPTY}
90
        * when the index does not exist or {@link  Status#VALID} if the index is valid
91
        * @throws IOException in case of IO problem
92
        * @since 1.5
93
        */
94
        Status getStatus (boolean tryOpen) throws IOException;
95
    }
96
85
    /**
97
    /**
86
     * An exception thrown by {@link Index} when operation is called on
98
     * An exception thrown by {@link Index} when operation is called on
87
     * a closed index.
99
     * a closed index.
88
     */
100
     */
89
    public static final class IndexClosedException extends IOException {        
101
    public static final class IndexClosedException extends IOException {        
90
    }
102
    }
91
        
103
    
104
    /**
105
     * Check if the index already exists
106
     * @return true if the index already exists on disk.
107
     */
108
    boolean exists ();
92
    
109
    
93
    /**
110
    /**
94
     * Checks the validity of the index. The index is invalid when it's broken.
111
     * Checks the validity of the index. The index is invalid when it's broken.
95
     * @param tryOpen when true the {@link Index} does exact but more expensive check.
112
     * @param tryOpen when true the {@link Index} does exact but more expensive check.
96
     * @return {@link Status#INVALID} when the index is broken, {@link Status#EMPTY}
113
     * @return true when {@link Index} is not broken
97
     * when the index does not exist or {@link  Status#VALID} if the index is valid
98
     * @throws IOException in case of IO problem
114
     * @throws IOException in case of IO problem
99
     * @since 2.1
100
     */
115
     */
101
    Status getStatus (boolean tryOpen) throws IOException;
116
    boolean isValid (boolean tryOpen) throws IOException;    
102
    
117
    
103
    /**
118
    /**
104
     * Queries the {@link Index} by given queries.
119
     * Queries the {@link Index} by given queries.

Return to bug 199808