Return-Path: X-Original-To: apmail-spark-commits-archive@minotaur.apache.org Delivered-To: apmail-spark-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8606517E29 for ; Mon, 10 Nov 2014 19:38:04 +0000 (UTC) Received: (qmail 97270 invoked by uid 500); 10 Nov 2014 19:38:04 -0000 Delivered-To: apmail-spark-commits-archive@spark.apache.org Received: (qmail 97242 invoked by uid 500); 10 Nov 2014 19:38:04 -0000 Mailing-List: contact commits-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@spark.apache.org Received: (qmail 97233 invoked by uid 99); 10 Nov 2014 19:38:04 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Nov 2014 19:38:04 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 18C349A42C9; Mon, 10 Nov 2014 19:38:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: andrewor14@apache.org To: commits@spark.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: spark git commit: [SPARK-4169] [Core] Accommodate non-English Locales in unit tests Date: Mon, 10 Nov 2014 19:38:03 +0000 (UTC) Repository: spark Updated Branches: refs/heads/branch-1.1 78cd3ab88 -> dc38defd2 [SPARK-4169] [Core] Accommodate non-English Locales in unit tests For me the core tests failed because there are two locale dependent parts in the code. Look at the Jira ticket for details. Why is it necessary to check the exception message in isBindCollision in https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/util/Utils.scala#L1686 ? Author: Niklas Wilcke <1wilcke@informatik.uni-hamburg.de> Closes #3036 from numbnut/core-test-fix and squashes the following commits: 1fb0d04 [Niklas Wilcke] Fixing locale dependend code and tests (cherry picked from commit ed8bf1eac548577c4bbad7ce3f7f301a2f52ef17) Signed-off-by: Andrew Or Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/dc38defd Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/dc38defd Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/dc38defd Branch: refs/heads/branch-1.1 Commit: dc38defd24803b2d51168da997552c45f33242c3 Parents: 78cd3ab Author: Niklas Wilcke <1wilcke@informatik.uni-hamburg.de> Authored: Mon Nov 10 11:37:38 2014 -0800 Committer: Andrew Or Committed: Mon Nov 10 11:37:59 2014 -0800 ---------------------------------------------------------------------- .../scala/org/apache/spark/util/Utils.scala | 2 +- .../org/apache/spark/util/UtilsSuite.scala | 25 +++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/dc38defd/core/src/main/scala/org/apache/spark/util/Utils.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala index 6d3bef0..a9371c8 100644 --- a/core/src/main/scala/org/apache/spark/util/Utils.scala +++ b/core/src/main/scala/org/apache/spark/util/Utils.scala @@ -1528,7 +1528,7 @@ private[spark] object Utils extends Logging { def isBindCollision(exception: Throwable): Boolean = { exception match { case e: BindException => - if (e.getMessage != null && e.getMessage.contains("Address already in use")) { + if (e.getMessage != null) { return true } isBindCollision(e.getCause) http://git-wip-us.apache.org/repos/asf/spark/blob/dc38defd/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala ---------------------------------------------------------------------- diff --git a/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala b/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala index 70d423b..a530e0b 100644 --- a/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala +++ b/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala @@ -22,6 +22,8 @@ import scala.util.Random import java.io.{File, ByteArrayOutputStream, ByteArrayInputStream, FileOutputStream} import java.net.{BindException, ServerSocket, URI} import java.nio.{ByteBuffer, ByteOrder} +import java.text.DecimalFormatSymbols +import java.util.Locale import com.google.common.base.Charsets import com.google.common.io.Files @@ -101,14 +103,16 @@ class UtilsSuite extends FunSuite { val hour = minute * 60 def str = Utils.msDurationToString(_) + val sep = new DecimalFormatSymbols(Locale.getDefault()).getDecimalSeparator() + assert(str(123) === "123 ms") - assert(str(second) === "1.0 s") - assert(str(second + 462) === "1.5 s") - assert(str(hour) === "1.00 h") - assert(str(minute) === "1.0 m") - assert(str(minute + 4 * second + 34) === "1.1 m") - assert(str(10 * hour + minute + 4 * second) === "10.02 h") - assert(str(10 * hour + 59 * minute + 59 * second + 999) === "11.00 h") + assert(str(second) === "1" + sep + "0 s") + assert(str(second + 462) === "1" + sep + "5 s") + assert(str(hour) === "1" + sep + "00 h") + assert(str(minute) === "1" + sep + "0 m") + assert(str(minute + 4 * second + 34) === "1" + sep + "1 m") + assert(str(10 * hour + minute + 4 * second) === "10" + sep + "02 h") + assert(str(10 * hour + 59 * minute + 59 * second + 999) === "11" + sep + "00 h") } test("reading offset bytes of a file") { @@ -271,12 +275,11 @@ class UtilsSuite extends FunSuite { assert(!Utils.isBindCollision(new Exception)) assert(!Utils.isBindCollision(new Exception(new Exception))) assert(!Utils.isBindCollision(new Exception(new BindException))) - assert(!Utils.isBindCollision(new Exception(new BindException("Random message")))) // Positives - val be = new BindException("Address already in use") - val be1 = new Exception(new BindException("Address already in use")) - val be2 = new Exception(new Exception(new BindException("Address already in use"))) + val be = new BindException("Random Message") + val be1 = new Exception(new BindException("Random Message")) + val be2 = new Exception(new Exception(new BindException("Random Message"))) assert(Utils.isBindCollision(be)) assert(Utils.isBindCollision(be1)) assert(Utils.isBindCollision(be2)) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org For additional commands, e-mail: commits-help@spark.apache.org