Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340955 - Missing "throw" in AbstractChannel.setServiceProxy
Summary: Missing "throw" in AbstractChannel.setServiceProxy
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Core (show other bugs)
Version: 0.3   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 0.4.0   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-25 09:27 EDT by Anton Leherbauer CLA
Modified: 2013-06-05 05:53 EDT (History)
1 user (show)

See Also:


Attachments
Insert "throw" keyword (1018 bytes, patch)
2011-03-25 09:27 EDT, Anton Leherbauer CLA
cdtdoug: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Leherbauer CLA 2011-03-25 09:27:02 EDT
Created attachment 191907 [details]
Insert "throw" keyword

By accident I stumbled across this line in AbstractChannel.setServiceProxy():

        if (!notifying_channel_opened) new Error("setServiceProxe() can be called only from channel open call-back");

which is obviously missing the "throw" keyword.
Attached patch fixes this.
Comment 1 Eugene Tarassov CLA 2011-03-25 13:04:38 EDT
This is intentional.

From Java language specs:

11.2.1 Why Errors are Not Checked

Those unchecked exception classes which are the error classes (Error and its subclasses) are exempted from compile-time checking because they can occur at many points in the program and recovery from them is difficult or impossible. A Java program declaring such exceptions would be cluttered, pointlessly.


And I like this particular exception to be Error - to make recovery difficult or impossible. The intend is to kill a client immediately if it does not honor API contract.
Comment 2 Anton Leherbauer CLA 2011-03-28 02:51:15 EDT
I think there is a misunderstanding.  I don't suggest to add a throws clause to the method declaration.  Sorry if I was not clear.

The issue is that the line

  if (!notifying_channel_opened) new Error(...);

is obsolete without "throw" before "new", i.e. it should be

  if (!notifying_channel_opened) throw new Error(...);

That's all.
Comment 3 Eugene Tarassov CLA 2011-03-28 11:56:44 EDT
Of course, you are absolutely right. My fault - I misunderstood you.
Committed the patch.
Thanks!