Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8154724

BigInteger Constructor throws a number format exception with hex numbers

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_77"
      Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
      Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux mirkwood 4.4.0-12-generic #28-Ubuntu SMP Wed Mar 9 00:33:55 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      BigInteger num = new BigInteger("cb459", 16);

      throws

      java.lang.NumberFormatException: For input string: "cb459""
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      at java.lang.Integer.parseInt(Integer.java:580)
      at java.math.BigInteger.<init>(BigInteger.java:461)
      at com.snapcard.core.blockchain.interfaces.model.EthBlock.fromStrings(EthBlock.java:63)
      at com.snapcard.core.blockchain.interfaces.model.EthBlock.<init>(EthBlock.java:97)
      at com.snapcard.core.blockchain.interfaces.eth.EthJsonRpcClient.lambda$getBlockByNumber$10(EthJsonRpcClient.java:114)
      at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:54)
      at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:54)
      at com.snapcard.core.util.httpclient.FuckVertxHttpClient$RequestLifecycle$1.lambda$completed$0(FuckVertxHttpClient.java:384)
      at com.snapcard.core.util.MockVertx.lambda$runOnContext$3(MockVertx.java:154)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Put in a hex number like "cb459" to BigInteger

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      new BigInteger("cb459", 16).toString(10) should yield 832601
      ACTUAL -
      java.lang.NumberFormatException: For input string: "cb459""
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      at java.lang.Integer.parseInt(Integer.java:580)
      at java.math.BigInteger.<init>(BigInteger.java:461)
      at com.snapcard.core.blockchain.interfaces.model.EthBlock.fromStrings(EthBlock.java:63)
      at com.snapcard.core.blockchain.interfaces.model.EthBlock.<init>(EthBlock.java:97)
      at com.snapcard.core.blockchain.interfaces.eth.EthJsonRpcClient.lambda$getBlockByNumber$10(EthJsonRpcClient.java:114)
      at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:54)
      at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:54)
      at com.snapcard.core.util.httpclient.FuckVertxHttpClient$RequestLifecycle$1.lambda$completed$0(FuckVertxHttpClient.java:384)
      at com.snapcard.core.util.MockVertx.lambda$runOnContext$3(MockVertx.java:154)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.NumberFormatException: For input string: "cb459""
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      at java.lang.Integer.parseInt(Integer.java:580)
      at java.math.BigInteger.<init>(BigInteger.java:461)
      at com.snapcard.core.blockchain.interfaces.model.EthBlock.fromStrings(EthBlock.java:63)
      at com.snapcard.core.blockchain.interfaces.model.EthBlock.<init>(EthBlock.java:97)
      at com.snapcard.core.blockchain.interfaces.eth.EthJsonRpcClient.lambda$getBlockByNumber$10(EthJsonRpcClient.java:114)
      at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:54)
      at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:54)
      at com.snapcard.core.util.httpclient.FuckVertxHttpClient$RequestLifecycle$1.lambda$completed$0(FuckVertxHttpClient.java:384)
      at com.snapcard.core.util.MockVertx.lambda$runOnContext$3(MockVertx.java:154)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      BigInteger num = new BigInteger("cb459", 16);

      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            • Assignee:
              psonal Pallavi Sonal (Inactive)
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: