mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 14:15:23 +02:00
Part of PR 68246.
Close the inputstream to release resource handle when we done with it, we can not rely on the GC to do it for us.
This commit is contained in:
parent
36ec31dca2
commit
dbaa2dcea9
10 changed files with 97 additions and 12 deletions
|
@ -1,3 +1,10 @@
|
|||
2004-06-22 Alain Magloire
|
||||
Part of PR 68246.
|
||||
Close the inputstream to release resource handle
|
||||
when we done with it, we can not rely on the GC to do it for us.
|
||||
|
||||
* src/org/eclipse/cdt/core/parsre/ParserUtil.java
|
||||
|
||||
2004-06-22 Alain Magloire
|
||||
|
||||
Fix the exclusion scheme in IPathEntry.
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2004-06-22 Alain Magloire
|
||||
Part of PR 68246.
|
||||
Close the inputstream to release resource handle
|
||||
when we done with it, we can not rely on the GC to do it for us.
|
||||
|
||||
* browser/org/eclipse/cdt/internal/core/browser/cache/TypeParser.java
|
||||
|
||||
2004-06-21 Chris Wiebe
|
||||
|
||||
- fix for bug #66108 (C++ browser cannot show members of class)
|
||||
|
|
|
@ -371,13 +371,22 @@ public class TypeParser implements ISourceElementRequestor {
|
|||
CodeReader reader = null;
|
||||
if (resource.isAccessible() && resource instanceof IFile) {
|
||||
IFile file = (IFile) resource;
|
||||
InputStream contents = null;
|
||||
try {
|
||||
InputStream contents = file.getContents();
|
||||
contents = file.getContents();
|
||||
if (contents != null)
|
||||
reader = new CodeReader(resource.getLocation().toOSString(), contents);
|
||||
} catch (CoreException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
} finally {
|
||||
if (contents != null) {
|
||||
try {
|
||||
contents.close();
|
||||
} catch (IOException io) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return reader;
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
2004-06-22 Alain Magloire
|
||||
|
||||
Part of PR 68246.
|
||||
Close the inputstream to release resource handle
|
||||
when we done with it, we can not rely on the GC to do it for us.
|
||||
|
||||
* index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
|
||||
|
||||
2004-06-21 Andrew Niefer
|
||||
enable reporting of semantic problems:
|
||||
* index/org/eclipse/cdt/internal/core/search/indexing/IndexManager.java
|
||||
|
|
|
@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.core.search.indexing;
|
|||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
|
@ -98,16 +99,20 @@ public class SourceIndexer extends AbstractIndexer {
|
|||
ParserLanguage language = CoreModel.hasCCNature(currentProject) ? ParserLanguage.CPP : ParserLanguage.C;
|
||||
|
||||
IParser parser = null;
|
||||
|
||||
try
|
||||
{
|
||||
CodeReader reader = new CodeReader(resourceFile.getLocation().toOSString(), resourceFile.getContents());
|
||||
|
||||
InputStream contents = null;
|
||||
try {
|
||||
contents = resourceFile.getContents();
|
||||
CodeReader reader = new CodeReader(resourceFile.getLocation().toOSString(), contents);
|
||||
parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, language, requestor, ParserUtil.getScannerLogService(), null ),
|
||||
requestor, ParserMode.COMPLETE_PARSE, language, ParserUtil.getParserLogService() );
|
||||
} catch( ParserFactoryError pfe )
|
||||
{
|
||||
} catch( ParserFactoryError pfe ){
|
||||
} catch (CoreException e) {
|
||||
} finally {
|
||||
if (contents != null) {
|
||||
contents.close();
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
2004-06-22 Alain Magloire
|
||||
|
||||
Part of PR 68246.
|
||||
Close the inputstream to release resource handle
|
||||
when we done with it, we can not rely on the GC to do it for us.
|
||||
|
||||
* parser/org/eclipse/cdt/core/parser/CodeReader.java
|
||||
|
||||
2004-04-23 Andrew Niefer
|
||||
- fixed up CompleteParseASTFactory.lookupQualifiedName in the case where the
|
||||
tokenDuple has 1 segement
|
||||
|
|
|
@ -47,7 +47,11 @@ public class CodeReader {
|
|||
this.filename = filename;
|
||||
|
||||
FileInputStream stream = new FileInputStream(filename);
|
||||
buffer = load(stream);
|
||||
try {
|
||||
buffer = load(stream);
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
|
||||
// If you have a handle on a stream to the file, e.g. IFile.getContents()
|
||||
|
@ -58,7 +62,15 @@ public class CodeReader {
|
|||
(stream instanceof FileInputStream)
|
||||
? (FileInputStream)stream
|
||||
: new FileInputStream(filename);
|
||||
buffer = load(fstream);
|
||||
try {
|
||||
buffer = load(fstream);
|
||||
} finally {
|
||||
// If we create the FileInputStream we need close to it when done,
|
||||
// if not we figure the above layer will do it.
|
||||
if (!(stream instanceof FileInputStream)) {
|
||||
fstream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private char[] load(FileInputStream stream) throws IOException {
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2004-06-22 Alain Magloire
|
||||
Part of PR 68246.
|
||||
Close the inputstream to release resource handle
|
||||
when we done with it, we can not rely on the GC to do it for us.
|
||||
|
||||
* search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java
|
||||
|
||||
2004-06-21 Bogdan Gheorghe
|
||||
Modified JobManager to change state from waiting to enabled on a job request.
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
package org.eclipse.cdt.internal.core.search.matching;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
@ -404,12 +405,14 @@ public class MatchLocator implements IMatchLocator{
|
|||
}
|
||||
} else {
|
||||
currentResource = workspaceRoot.findMember( pathString, true );
|
||||
|
||||
|
||||
InputStream contents = null;
|
||||
try{
|
||||
if( currentResource != null ){
|
||||
if (currentResource.isAccessible() && currentResource instanceof IFile) {
|
||||
IFile file = (IFile) currentResource;
|
||||
reader = new CodeReader(currentResource.getLocation().toOSString(), file.getContents());
|
||||
contents = file.getContents();
|
||||
reader = new CodeReader(currentResource.getLocation().toOSString(), contents);
|
||||
realPath = currentResource.getLocation();
|
||||
project = file.getProject();
|
||||
} else {
|
||||
|
@ -420,6 +423,14 @@ public class MatchLocator implements IMatchLocator{
|
|||
continue;
|
||||
} catch ( IOException e ) {
|
||||
continue;
|
||||
} finally {
|
||||
if (contents != null) {
|
||||
try {
|
||||
contents.close();
|
||||
} catch (IOException io) {
|
||||
// ignore.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
|
@ -65,7 +66,17 @@ public class ParserUtil
|
|||
if( buffer != null )
|
||||
return new CodeReader(finalPath, buffer);
|
||||
}
|
||||
return new CodeReader(finalPath, ((IFile)resultingResource).getContents());
|
||||
InputStream in = null;
|
||||
try
|
||||
{
|
||||
in = ((IFile)resultingResource).getContents();
|
||||
return new CodeReader(finalPath, in);
|
||||
} finally {
|
||||
if (in != null)
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( CoreException ce )
|
||||
|
|
Loading…
Add table
Reference in a new issue