Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 167525 - [67cat] NumberFormatException: For input string: "tns:key"
[67cat] NumberFormatException: For input string: "tns:key"
Status: RESOLVED FIXED
Product: xml
Classification: Unclassified
Component: Schema Model
6.x
All All
: P3 (vote)
: 6.x
Assigned To: Nikita Krjukov
issues@xml
http://statistics.netbeans.org/except...
EXCEPTIONS_REPORT
: NETFIX
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-23 11:11 UTC by dynamite
Modified: 2010-04-14 04:43 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
stacktrace (4.59 KB, text/plain)
2009-06-23 11:11 UTC, dynamite
Details
proposed patch (3.24 KB, patch)
2010-03-30 21:45 UTC, dynamite
Details | Diff
updated patch including error in red text (3.53 KB, patch)
2010-04-01 19:21 UTC, dynamite
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description dynamite 2009-06-23 11:11:30 UTC
Build: NetBeans IDE Dev (Build 200906221401)
VM: Java HotSpot(TM) Client VM, 14.0-b16, Java(TM) SE Runtime Environment, 1.6.0_14-b08
OS: Windows XP, 5.1, x86

User Comments:
dynamite: I was manually editing the XML schema and converting a element from having an inline type to a declared type.  I errantly typed a non-numeric string (the type) into the attribute minOccurs which expected an integer and got this exception.  Red underlining of the attribute would be better.



Stacktrace: 
java.lang.NumberFormatException: For input string: "tns:key"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at java.lang.Integer.parseInt(Integer.java:449)
        at java.lang.Integer.valueOf(Integer.java:554)
        at org.netbeans.modules.xml.schema.model.impl.LocalElementBaseImpl.getMinOccurs(LocalElementBaseImpl.java:109)
        at org.netbeans.modules.xml.schema.model.impl.LocalElementBaseImpl.getMinOccursEffective(LocalElementBaseImpl.java:128)
        at org.netbeans.modules.xml.schema.ui.nodes.categorized.AdvancedLocalElementNode.getHtmlDisplayName(AdvancedLocalElementNode.java:85)
Comment 1 dynamite 2009-06-23 11:11:36 UTC
Created attachment 83919 [details]
stacktrace
Comment 2 Jiri Kovalsky 2010-03-25 14:36:49 UTC
Daniel, can you still reproduce this issue? It works fine for me i.e. no exception was thrown but also no red underlining. :-\

If you can't reproduce it, let's close the bug. If you can, don't you want to try NetFIX it? ;-)
Comment 3 Jiri Kovalsky 2010-03-26 14:47:58 UTC
This issue was added to the list of NetFIX [1] candidates. If module owner does not agree, please speak up. Thanks!

[1] http://wiki.netbeans.org/NetFIXIssues
Comment 4 dynamite 2010-03-30 21:45:34 UTC
Created attachment 96385 [details]
proposed patch

The problem shows when the "XML Schema and WSDL" module is installed. The minOccurs shows in the design view.  The existing code looks up the minOccurs as an integer, but if the document is invalid then it may be non-integer text.
Comment 5 Sergey Lunegov 2010-04-01 06:28:45 UTC
Nikita, please review the suggested fix and apply if everything is correct.
Comment 6 Nikita Krjukov 2010-04-01 15:56:57 UTC
As I understand right, the patch helps to get rid of the exception. But an incorrectly typed value will appear in the property sheet. 

It looks well from one side because it helps avoid the exception appearing. But 
it can confuse the user with appearing incorrect value in property sheet. 

Maybe it's better continue calling getMinOccuresEffective() inside of AdvancedLocalElementNode.getHtmlDisplayName() but with catching the NumberFormatException. In case of exception the HTML text can be colored in red (with HTML tags) and shows a text like "Incorrect value". 

There is another advantage of the method getMinOccuresEffective(). It returns a default value in case the attribute isn't defined at all. With your path the property will show "null" if there isn't the attribute.
Comment 7 dynamite 2010-04-01 19:21:20 UTC
Created attachment 96553 [details]
updated patch including error in red text

Updated patch to match the above comment.  When minOccurs is not an integer then it is now shown in red.
Comment 8 Jiri Kovalsky 2010-04-08 12:06:14 UTC
Nikita, any update on this? Thanks a lot!
Comment 9 Nikita Krjukov 2010-04-13 17:42:41 UTC
Fixed in trunk http://hg.netbeans.org/main/rev/ee5d954b53a0

I applied the latest suggested update with some restrictions. 
Adding new method LocalElement.getMinOccursText() is an API modification. 
It requires more serious efforts and motivations and I remove it from the fix. 

There is another problem. An incorrect (non numeric) minOccur value causes exception anyway. So the fix cover only part of problem. The exception happens if click on the erroneous value in property sheet. Unfortunately, it doesn't look like easy to fix.
Comment 10 Jiri Kovalsky 2010-04-13 17:57:57 UTC
Great, thanks for your review & integration Nikita and special thanks to Daniel for the patch!
Comment 11 Quality Engineering 2010-04-14 04:43:12 UTC
Integrated into 'main-golden', will be available in build *201004140201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ee5d954b53a0
User: supernikita@netbeans.org
Log: #167525 - NumberFomatException while entering non numeric value for minValue


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo