Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 73518 Details for
Bug 97998
[builder] improve the error handling in case the build encounters a locked file within the the output folder
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fix + test case
patch.txt (text/plain), 7.91 KB, created by
Maxime Daniel
on 2007-07-11 04:52:05 EDT
(
hide
)
Description:
Fix + test case
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2007-07-11 04:52:05 EDT
Size:
7.91 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/builder/ImageBuilderInternalException.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ImageBuilderInternalException.java,v >retrieving revision 1.10 >diff -u -r1.10 ImageBuilderInternalException.java >--- model/org/eclipse/jdt/internal/core/builder/ImageBuilderInternalException.java 10 May 2006 18:03:50 -0000 1.10 >+++ model/org/eclipse/jdt/internal/core/builder/ImageBuilderInternalException.java 11 Jul 2007 08:49:38 -0000 >@@ -25,16 +25,6 @@ > this.coreException = e; > } > >-public String getLocalizedMessage() { >- IStatus status = this.coreException.getStatus(); >- if (status.isMultiStatus()) { >- IStatus[] children = status.getChildren(); >- if (children != null && children.length > 0) >- return children[0].getMessage(); >- } >- return this.coreException.getLocalizedMessage(); >-} >- > public CoreException getThrowable() { > return coreException; > } >Index: model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java,v >retrieving revision 1.132 >diff -u -r1.132 JavaBuilder.java >--- model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java 9 May 2007 14:21:18 -0000 1.132 >+++ model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java 11 Jul 2007 08:49:38 -0000 >@@ -209,28 +209,10 @@ > } > } catch (CoreException e) { > Util.log(e, "JavaBuilder handling CoreException while building: " + currentProject.getName()); //$NON-NLS-1$ >- IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); >- marker.setAttributes( >- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID}, >- new Object[] { >- Messages.bind(Messages.build_inconsistentProject, e.getLocalizedMessage()), >- new Integer(IMarker.SEVERITY_ERROR), >- new Integer(CategorizedProblem.CAT_BUILDPATH), >- JavaBuilder.SOURCE_ID >- } >- ); >+ createInconsistentBuildMarker(e); > } catch (ImageBuilderInternalException e) { > Util.log(e.getThrowable(), "JavaBuilder handling ImageBuilderInternalException while building: " + currentProject.getName()); //$NON-NLS-1$ >- IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); >- marker.setAttributes( >- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID}, >- new Object[] { >- Messages.bind(Messages.build_inconsistentProject, e.getLocalizedMessage()), >- new Integer(IMarker.SEVERITY_ERROR), >- new Integer(CategorizedProblem.CAT_BUILDPATH), >- JavaBuilder.SOURCE_ID >- } >- ); >+ createInconsistentBuildMarker(e.coreException); > } catch (MissingSourceFileException e) { > // do not log this exception since its thrown to handle aborted compiles because of missing source files > if (DEBUG) >@@ -306,15 +288,7 @@ > new BatchImageBuilder(this, false).cleanOutputFolders(false); > } catch (CoreException e) { > Util.log(e, "JavaBuilder handling CoreException while cleaning: " + currentProject.getName()); //$NON-NLS-1$ >- IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); >- marker.setAttributes( >- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IMarker.SOURCE_ID}, >- new Object[] { >- Messages.bind(Messages.build_inconsistentProject, e.getLocalizedMessage()), >- new Integer(IMarker.SEVERITY_ERROR), >- JavaBuilder.SOURCE_ID >- } >- ); >+ createInconsistentBuildMarker(e); > } finally { > notifier.done(); > cleanup(); >@@ -324,6 +298,29 @@ > + " @ " + new Date(System.currentTimeMillis())); //$NON-NLS-1$ > } > >+private void createInconsistentBuildMarker(CoreException coreException) throws CoreException { >+ String message = null; >+ IStatus status = coreException.getStatus(); >+ if (status.isMultiStatus()) { >+ IStatus[] children = status.getChildren(); >+ if (children != null && children.length > 0) >+ message = children[0].getMessage(); >+ } >+ if (message == null) >+ message = coreException.getMessage(); >+ >+ IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); >+ marker.setAttributes( >+ new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID}, >+ new Object[] { >+ Messages.bind(Messages.build_inconsistentProject, message), >+ new Integer(IMarker.SEVERITY_ERROR), >+ new Integer(CategorizedProblem.CAT_BUILDPATH), >+ JavaBuilder.SOURCE_ID >+ } >+ ); >+} >+ > private void cleanup() { > this.participants = null; > this.nameEnvironment = null; >#P org.eclipse.jdt.core.tests.builder >Index: src/org/eclipse/jdt/core/tests/builder/ErrorsTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ErrorsTests.java,v >retrieving revision 1.21 >diff -u -r1.21 ErrorsTests.java >--- src/org/eclipse/jdt/core/tests/builder/ErrorsTests.java 2 Feb 2007 17:28:57 -0000 1.21 >+++ src/org/eclipse/jdt/core/tests/builder/ErrorsTests.java 11 Jul 2007 08:49:39 -0000 >@@ -10,9 +10,13 @@ > *******************************************************************************/ > package org.eclipse.jdt.core.tests.builder; > >+import java.io.File; >+import java.io.IOException; >+ > import junit.framework.*; > > import org.eclipse.core.resources.IMarker; >+import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IPath; > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.compiler.CategorizedProblem; >@@ -193,4 +197,56 @@ > new Problem("p1", "The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files", classTest1, 0, 1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR)); > assertEquals(JavaBuilder.SOURCE_ID, prob1[0].getSourceId()); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97998 >+// Improving the error message in case of a read-only file in output >+// directory. Beware: this test only works under Linux - execution on other >+// platforms always succeeds, but the result is not significant. >+public void test0105() throws JavaModelException, CoreException, IOException { >+ if ("Linux".equals(System.getProperty("os.name"))) { >+ IPath projectPath = env.addProject("P"); >+ env.addExternalJars(projectPath, Util.getJavaClassLibs()); >+ IPath root = env.getPackageFragmentRootPath(projectPath, ""); >+ IPath outputFolderPath = env.getOutputLocation(projectPath); >+ File outputFolder = env.getWorkspaceRootPath().append(outputFolderPath).toFile(); >+ env.addClass(root, "p1", >+ "X", >+ "package p1;\n" + >+ "public class X {\n" + >+ "}\n" >+ ); >+ try { >+ fullBuild(projectPath); >+ expectingNoProblems(); >+ outputFolder.setReadOnly(); >+ // outputFolder.setReadable(false); >+ // PREMATURE no appropriate solution for Windows/NTFS/JDK 1.4 >+ cleanBuild(); >+ expectingOnlySpecificProblemFor(env.getWorkspaceRootPath(), >+ new Problem("", >+ "The project was not built due to \"Could not delete \'" + >+ env.getWorkspaceRootPath() + "/P/bin/.classpath\'.\". " + >+ "Fix the problem, then try refreshing this project and building " + >+ "it since it may be inconsistent", projectPath, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR)); >+ } finally { >+ // waiting for JDK 6: outputFolder.setWritable(true); -- workaround: >+ try { >+ Runtime.getRuntime().exec("chmod -R a+w " + outputFolder.getAbsolutePath()).waitFor(); >+ } catch (InterruptedException e) { >+ // go ahead >+ } >+ } >+ try { >+ cleanBuild(); >+ expectingNoProblems(); >+ } catch (Throwable t) { >+ try { >+ Runtime.getRuntime().exec("chmod -R a+w " + outputFolder.getAbsolutePath()).waitFor(); >+ } catch (InterruptedException ie) { >+ // go ahead >+ } >+ fail(t.getMessage()); >+ } >+ } >+} > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 97998
:
70327
|
72726
| 73518