Bug 29735 - NPE trying to surround some code with try/catch
Summary: NPE trying to surround some code with try/catch
Status: RESOLVED DUPLICATE of bug 29549
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-17 13:56 EST by Olivier Thomann CLA
Modified: 2003-01-20 03:53 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2003-01-17 13:56:20 EST
Using 0115, I got this stacktrace:

java.lang.NullPointerException
	at
org.eclipse.jdt.internal.corext.refactoring.changes.TextFileChange.perform(TextFileChange.java:203)
	at
org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation$1.run(PerformChangeOperation.java:173)
	at
org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:34)
	at
org.eclipse.jdt.internal.core.JavaModelOperation.execute(JavaModelOperation.java:326)
	at
org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:626)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1580)
	at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:2570)
	at
org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:183)
	at
org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:151)
	at
org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.internalRun(BusyIndicatorRunnableContext.java:107)
	at
org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.run(BusyIndicatorRunnableContext.java:74)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:65)
	at
org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext.run(BusyIndicatorRunnableContext.java:120)
	at
org.eclipse.jdt.ui.actions.SurroundWithTryCatchAction.run(SurroundWithTryCatchAction.java:110)
	at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:193)
	at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:169)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:804)
	at
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:422)
	at
org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java:374)
	at
org.eclipse.jface.action.ActionContributionItem.access$0(ActionContributionItem.java:368)
	at
org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java:69)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:836)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1692)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1410)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1467)
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:1450)
	at
org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:845)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:247)
	at org.eclipse.core.launcher.Main.run(Main.java:703)
	at org.eclipse.core.launcher.Main.main(Main.java:539)

The code I tried to surround with try/catch is:
BufferedWriter writer = new BufferedWriter(new FileWriter("d:/temp/compiler.log"));
for (Iterator iterator = this.set.iterator(); iterator.hasNext(); ) {
	writer.write(iterator.next());
}
writer.flush();
writer.close();
Comment 1 Dirk Baeumer CLA 2003-01-20 03:53:24 EST

*** This bug has been marked as a duplicate of 29549 ***