infiniteam / avacodo

GNU Lesser General Public License v2.1
2 stars 0 forks source link

class can't be instanced within windows #6

Closed arathorn2005 closed 10 years ago

arathorn2005 commented 10 years ago

While testing your class on different enviroments I've encountered an issue, which occurs when working on a windows machine:

C:\>java -jar avacodo.jar my.csv -b 3 -a 4
Exception in thread "main" java.lang.ExceptionInInitializerError
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.avacodo.conversion.iban.rules.Rules.<init>(Rules.java:101)
        at org.avacodo.conversion.iban.rules.Rules.<clinit>(Rules.java:33)
        at org.avacodo.conversion.iban.rules.RuleBasedIbanCalculator.getIban(RuleBasedIbanCalculator.java:60)
        at org.avacodo.conversion.iban.rules.RuleBasedIbanCalculator.getIban(RuleBasedIbanCalculator.java:47)
        at org.avacodo.filebased.SimpleCsvConverter.getResult(SimpleCsvConverter.java:307)
        at org.avacodo.filebased.SimpleCsvConverter.processLine(SimpleCsvConverter.java:214)
        at com.google.common.io.CharStreams.readLines(CharStreams.java:369)
        at com.google.common.io.CharStreams.readLines(CharStreams.java:394)
        at com.google.common.io.Files.readLines(Files.java:706)
        at org.avacodo.filebased.SimpleCsvConverter.main(SimpleCsvConverter.java:90)
"aused by: java.lang.NumberFormatException: For input string: "79080052
        at java.lang.NumberFormatException.forInputString(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at org.avacodo.conversion.iban.rules.Rule000500$1$2.apply(Rule000500.java:104)
        at org.avacodo.conversion.iban.rules.Rule000500$1$2.apply(Rule000500.java:102)
        at org.eclipse.xtext.xbase.lib.internal.FunctionDelegate.apply(FunctionDelegate.java:41)
        at com.google.common.collect.Iterators$8.transform(Iterators.java:860)
        at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
        at com.google.common.collect.Sets.newLinkedHashSet(Sets.java:295)
        at org.eclipse.xtext.xbase.lib.IterableExtensions.toSet(IterableExtensions.java:693)
        at org.avacodo.conversion.iban.rules.Rule000500$1.apply(Rule000500.java:109)
        at org.avacodo.conversion.iban.rules.Rule000500.<clinit>(Rule000500.java:48)
        ... 14 more

The exact same command works within a linux enviroment and produces a valid result.

Additional information:

C:\>java -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode, sharing)

Thanks in advance!

oehme commented 10 years ago

As already discussed: Splitting a String by \n does not work if it is delimited by Windows-style delimiters.

On a side note: Why use a String anyway? What you want is a list of Integers and Xtend has nice List literals. Just use those =)

arathorn2005 commented 10 years ago

I can only comment from my csv experiences, since I'm not yet that fluent in Java. If I read it properly, you might want to detect the systems "default" by using something like

System.getProperty("line.separator")

From a csv's perspective, I frequently coded different data separators. In this use case it wouldn't make that much sense, but generally a variable data separator might be of some help.

oehme commented 10 years ago

Oh, this is not a CSV parsing issue. It is a coding error in one of our classes itself. My comment was not directed at you, but at Alexander Nittka. I was talking about an implementation detail. Sorry to confuse you ;)

But you are right, CSV parsing could also be parametrized. Feel free to open another issue if you need support for other delimiters etc.

nittka commented 10 years ago

You can already specify the separator. However, this first quick and dirty implementation is not intended to be a full-fledged csv processor.

arathorn2005 commented 10 years ago

Totally agree. As mentioned yesterday, in most use cases it wouldn't make that much sense to implement every csv varations there is.

oehme commented 10 years ago

Fixed in master