소스 검색

HADOOP-3301. Fix misleading error message when S3 URI hostname
contains an underscore. Contributed by Tom White.


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@652125 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 17 년 전
부모
커밋
3adff4db72
3개의 변경된 파일43개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      CHANGES.txt
  2. 4 0
      src/java/org/apache/hadoop/fs/s3/Jets3tFileSystemStore.java
  3. 36 0
      src/test/org/apache/hadoop/fs/s3/TestS3Uri.java

+ 3 - 0
CHANGES.txt

@@ -105,6 +105,9 @@ Trunk (unreleased changes)
     HADOOP-3318. Recognize "Darwin" as an alias for "Mac OS X" to
     support Soylatte. (Sam Pullara via omalley)
 
+    HADOOP-3301. Fix misleading error message when S3 URI hostname
+    contains an underscore. (tomwhite via omalley)
+
 Release 0.17.0 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 4 - 0
src/java/org/apache/hadoop/fs/s3/Jets3tFileSystemStore.java

@@ -78,6 +78,10 @@ class Jets3tFileSystemStore implements FileSystemStore {
     
     this.conf = conf;
     
+    if (uri.getHost() == null) {
+      throw new IllegalArgumentException("Invalid hostname in URI " + uri); 
+    }
+    
     try {
       String accessKey = null;
       String secretAccessKey = null;

+ 36 - 0
src/test/org/apache/hadoop/fs/s3/TestS3Uri.java

@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.fs.s3;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.hadoop.conf.Configuration;
+
+public class TestS3Uri extends TestCase {
+  public void testInvalidHostnameWithUnderscores() throws Exception {
+    FileSystemStore store = new Jets3tFileSystemStore();
+    try {
+      store.initialize(new URI("s3://a:b@c_d"), new Configuration());
+      fail("Should throw IllegalArgumentException");
+    } catch (IllegalArgumentException e) {
+      assertEquals("Invalid hostname in URI s3://a:b@c_d", e.getMessage());
+    }
+  }
+}