You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (JIRA)" <ji...@apache.org> on 2014/10/15 08:41:34 UTC

[jira] [Commented] (SPARK-3944) Utils.resolveURI fails on upgrading scalaVersion to 2.11.2

    [ https://issues.apache.org/jira/browse/SPARK-3944?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14172063#comment-14172063 ] 

Apache Spark commented on SPARK-3944:
-------------------------------------

User 'Shiti' has created a pull request for this issue:
https://github.com/apache/spark/pull/2810

> Utils.resolveURI fails on upgrading scalaVersion to 2.11.2
> ----------------------------------------------------------
>
>                 Key: SPARK-3944
>                 URL: https://issues.apache.org/jira/browse/SPARK-3944
>             Project: Spark
>          Issue Type: Sub-task
>          Components: Spark Core
>    Affects Versions: 1.1.0
>            Reporter: Shiti Saxena
>            Assignee: Shiti Saxena
>             Fix For: 1.2.0
>
>
> The method tries to match a String (`uri.getScheme`) to obtain the result. The value from `uri.getScheme` can be null. 
> Pattern matching using Regex when String value is null throws NPE in Scala 2.11.2. whereas it works in 2.10.4
> Running the same code snippet gives different results
> {noformat}
> Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_60).
> Type in expressions to have them evaluated.
> Type :help for more information.
> scala> val pattern = "(.*)".r
> pattern: scala.util.matching.Regex = (.*)
> scala> val x:String = null
> x: String = null
> scala> x match {   case pattern(x) => println("Success")
>      |       case null => println("Fail")
>      | }
> Fail
> scala> 
> {noformat}
> {noformat}
> Welcome to Scala version 2.11.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_60).
> Type in expressions to have them evaluated.
> Type :help for more information.
> scala> val pattern = "(.*)".r
> pattern: scala.util.matching.Regex = (.*)
> scala> val x:String = null
> x: String = null
> scala> x match {   case pattern(x) => println("Success")
>      |       case null => println("Fail")
>      |      }
> java.lang.NullPointerException
>   at java.util.regex.Matcher.getTextLength(Matcher.java:1234)
>   at java.util.regex.Matcher.reset(Matcher.java:308)
>   at java.util.regex.Matcher.<init>(Matcher.java:228)
>   at java.util.regex.Pattern.matcher(Pattern.java:1088)
>   at scala.util.matching.Regex.unapplySeq(Regex.scala:206)
>   ... 47 elided
> {noformat}
> This happens because, In scala 2.11.2 "the unapply" tries to match the regex even if the input is null. While in scala 2.10 it matches the correct case with out unapplying.    



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org