| Summary: | [nls tooling] PropertyKeyHyperlinkDetector throws IAE when file contains invalid unicode escape | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Markus Keller <markus.kell.r> |
| Component: | Text | Assignee: | Deepak Azad <deepakazad> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | daniel_megert |
| Version: | 3.7 | ||
| Target Milestone: | 3.7 M6 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
|
Description
Markus Keller
The call to Properties#load() in PropertyKeyHyperlinkDetector.detectHyperlinks(...) looks unnecessary to me. If the key in question is invalid, PropertyKeyHyperlinkDetector.getUnicodeString(...) would also complain. There is no need to check the whole file by calling Properties#load(). (In reply to comment #1) > The call to Properties#load() in > PropertyKeyHyperlinkDetector.detectHyperlinks(...) looks unnecessary to me. If > the key in question is invalid, > PropertyKeyHyperlinkDetector.getUnicodeString(...) would also complain. There > is no need to check the whole file by calling Properties#load(). We need the check to be 100% sure that the key is a real key in the properties list. Also note, that you won't be able to use that file as it will also fail to load when it tries to resolve one of the keys. We should write an error to the editor status line (see PropertyKeyHyperlink.showErrorInStatusLine(String)) and don't write to the .log. (In reply to comment #2) > We need the check to be 100% sure that the key is a real key in the properties > list. Ok... is there a scenario when the key is not a real key ? Honestly, I can not think of one, and hence think that the check is unnecessary. Plus we would save some cycles if we do not load the whole file. > Also note, that you won't be able to use that file as it will also fail > to load when it tries to resolve one of the keys. We should write an error to > the editor status line (see PropertyKeyHyperlink.showErrorInStatusLine(String)) > and don't write to the .log. Yeah.. that's there. The right thing to do is to mark it as an error in the editor (Bug 328374) and let the user know that about it even if he does not try to invoke a hyperlink. Also I see no point in preventing a user from opening a hyperlink just because there are some errors in the file - we do not do that in the Java editor as well. Having said that, since currently we do not mark it as an error, I was thinking of leaving the check as it is *for now*. > Ok... is there a scenario when the key is not a real key ? Honestly, I can not > think of one, and hence think that the check is unnecessary. Plus we would save > some cycles if we do not load the whole file. It's the other way around: if you want to remove the code you need to proof that the key is 100% valid ;-) > > > Also note, that you won't be able to use that file as it will also fail > > to load when it tries to resolve one of the keys. We should write an error to > > the editor status line (see PropertyKeyHyperlink.showErrorInStatusLine(String)) > > and don't write to the .log. > Yeah.. that's there. The right thing to do is to mark it as an error in the > editor (Bug 328374) and let the user know that about it even if he does not try > to invoke a hyperlink. As you just said: it's another bug. >Also I see no point in preventing a user from opening a > hyperlink just because there are some errors in the file - we do not do that >in > the Java editor as well. The hover also fails (see bug 328601) and the file is completely unusable with the (unseen) error. > Having said that, since currently we do not mark it as an error, I was thinking > of leaving the check as it is *for now*. Just write it to the status bar as we currently have other things to do than working on bug 328374. This would then also be consistent with the fix for the hover problem where we notify the user about the broken properties file. (In reply to comment #4) > Just write it to the status bar as we currently have other things to do than > working on bug 328374. This would then also be consistent with the fix for the > hover problem where we notify the user about the broken properties file. Fair enough. (In reply to comment #2) > We should write an error to > the editor status line (see PropertyKeyHyperlink.showErrorInStatusLine(String)) > and don't write to the .log. Fixed in HEAD in PropertyKeyHyperlinkDetector.java > Fixed in HEAD in PropertyKeyHyperlinkDetector.java
Why do we need the field fTextEditor? Can't you just pass the ITextEditor to showErrorInStatusLine? Avoiding state is always a plus.
(In reply to comment #7) > > Fixed in HEAD in PropertyKeyHyperlinkDetector.java > > Why do we need the field fTextEditor? Can't you just pass the ITextEditor to > showErrorInStatusLine? Avoiding state is always a plus. Ok, fixed in HEAD. |