File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
main/java/org/springframework/data/hadoop/configuration
test/java/org/springframework/data/hadoop/configuration Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 2323import org .apache .commons .logging .LogFactory ;
2424import org .apache .hadoop .conf .Configuration ;
2525import org .apache .hadoop .fs .FsUrlStreamHandlerFactory ;
26+ import org .apache .hadoop .security .UserGroupInformation ;
2627import org .springframework .beans .factory .BeanClassLoaderAware ;
2728import org .springframework .beans .factory .FactoryBean ;
2829import org .springframework .beans .factory .InitializingBean ;
@@ -67,6 +68,8 @@ public void afterPropertiesSet() throws Exception {
6768
6869 if (registerJvmUrl ) {
6970 try {
71+ // force UGI init to prevent infinite loop - see SHDP-92
72+ UserGroupInformation .setConfiguration (internalConfig );
7073 URL .setURLStreamHandlerFactory (new FsUrlStreamHandlerFactory (getObject ()));
7174 log .info ("Registered HDFS URL stream handler" );
7275 } catch (Error err ) {
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2011-2012 the original author or authors.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ package org .springframework .data .hadoop .configuration ;
17+
18+ import org .apache .hadoop .fs .FileSystem ;
19+ import org .junit .Test ;
20+
21+ import static org .junit .Assert .*;
22+
23+ /**
24+ * See SHDP-92: https://jira.springsource.org/browse/SHDP-92
25+ * @author Costin Leau
26+ */
27+ public class UrlInfiniteLoopTest {
28+
29+ @ Test
30+ public void testInfiniteLoop () throws Exception {
31+ ConfigurationFactoryBean factory = new ConfigurationFactoryBean ();
32+ factory .setRegisterUrlHandler (true );
33+ factory .afterPropertiesSet ();
34+ assertNotNull (factory .getObject ());
35+ FileSystem fs = FileSystem .get (factory .getObject ());
36+ assertNotNull (fs );
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments