@@ -42,32 +42,34 @@ public class DinkyClassLoader extends URLClassLoader {
42
42
FlinkUdfPathContextHolder udfPathContextHolder = new FlinkUdfPathContextHolder ();
43
43
44
44
public DinkyClassLoader (URL [] urls , ClassLoader parent ) {
45
- super ( new URL [] {} , parent );
45
+ this ( urls , parent , null );
46
46
}
47
47
48
48
public DinkyClassLoader (Collection <File > fileSet , ClassLoader parent ) {
49
- super (new URL [] {}, parent );
50
- addURLs (fileSet );
49
+ this (convertFilesToUrls (fileSet ), parent , null );
51
50
}
52
51
53
52
public DinkyClassLoader (URL [] urls ) {
54
- super ( new URL [] {} );
53
+ this ( urls , Thread . currentThread (). getContextClassLoader (), null );
55
54
}
56
55
57
56
public DinkyClassLoader (URL [] urls , ClassLoader parent , URLStreamHandlerFactory factory ) {
58
- super (new URL [] {}, parent , factory );
59
- }
60
-
61
- // this class factory method
62
- public static DinkyClassLoader build () {
63
- return new DinkyClassLoader (new URL [] {});
57
+ super (urls , parent , factory );
64
58
}
65
59
66
60
// class factory method with urls parameters
67
61
public static DinkyClassLoader build (URL ... urls ) {
68
62
return new DinkyClassLoader (urls );
69
63
}
70
64
65
+ public static DinkyClassLoader build (URL [] urls , ClassLoader parent ) {
66
+ return new DinkyClassLoader (urls , parent );
67
+ }
68
+
69
+ public static DinkyClassLoader build (ClassLoader parent ) {
70
+ return new DinkyClassLoader (new URL [] {}, parent );
71
+ }
72
+
71
73
// return udfPathContextHolder
72
74
public FlinkUdfPathContextHolder getUdfPathContextHolder () {
73
75
return udfPathContextHolder ;
@@ -80,30 +82,23 @@ public void addURLs(URL... urls) {
80
82
}
81
83
82
84
public void addURLs (Collection <File > fileSet ) {
83
- URL [] urls = fileSet .stream ()
84
- .map (x -> {
85
- try {
86
- return x .toURI ().toURL ();
87
- } catch (MalformedURLException e ) {
88
- throw new RuntimeException (e );
89
- }
90
- })
91
- .toArray (URL []::new );
85
+ URL [] urls = convertFilesToUrls (fileSet );
92
86
addURLs (urls );
93
87
}
94
88
95
- public void addURLs ( List <File > files ) {
96
- files .stream ()
89
+ private static URL [] convertFilesToUrls ( Collection <File > fileSet ) {
90
+ return fileSet .stream ()
97
91
.map (x -> {
98
92
try {
99
93
return x .toURI ().toURL ();
100
94
} catch (MalformedURLException e ) {
101
95
throw new RuntimeException (e );
102
96
}
103
97
})
104
- .forEach ( this :: addURL );
98
+ .toArray ( URL []:: new );
105
99
}
106
100
101
+ @ Override
107
102
public void addURL (URL url ) {
108
103
super .addURL (url );
109
104
}
0 commit comments