Skip to content

Commit 91e873a

Browse files
committed
optimzie_some_code
1 parent 0ee8278 commit 91e873a

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

dinky-admin/src/main/java/org/dinky/url/RsURLStreamHandlerFactory.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,26 @@
3333

3434
@Profile("!test")
3535
public class RsURLStreamHandlerFactory implements URLStreamHandlerFactory {
36-
private final List<String> notContains = Arrays.asList("jar", "file", "http", "https");
36+
private static final String PREFIX = "sun.net.www.protocol";
3737

3838
@Override
3939
public URLStreamHandler createURLStreamHandler(String protocol) {
40-
if ("rs".equals(protocol)) {
40+
if ("rs".equalsIgnoreCase(protocol)) {
4141
return new RsURLStreamHandler();
4242
}
43-
for (String tempProtocol : notContains) {
44-
if (tempProtocol.equals(StrUtil.sub(protocol, 0, tempProtocol.length()))) {
45-
return null;
46-
}
43+
String name = PREFIX + "." + protocol + ".Handler";
44+
try {
45+
@SuppressWarnings("deprecation")
46+
Object o = Class.forName(name).newInstance();
47+
return (URLStreamHandler) o;
48+
} catch (ClassNotFoundException x) {
49+
// ignore
50+
} catch (Exception e) {
51+
// For compatibility, all Exceptions are ignored.
52+
// any number of exceptions can get thrown here
4753
}
4854

55+
4956
try {
5057
Class.forName("org.apache.hadoop.fs.FsUrlStreamHandlerFactory");
5158
} catch (Exception e) {

dinky-app/dinky-app-base/src/main/java/org/dinky/app/flinksql/Submitter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public static Optional<JobClient> executeJarJob(String type, Executor executor,
259259
ReadableConfig configuration =
260260
executor.getStreamExecutionEnvironment().getConfiguration();
261261
List<String> jars = configuration.get(PipelineOptions.JARS);
262-
List<URL> jarsUrl = jars.stream().map(URLUtil::getURL).collect(Collectors.toList());
262+
List<URL> jarsUrl = jars.stream().map(URLUtil::url).collect(Collectors.toList());
263263
Pipeline pipeline = executeJarOperation.getStreamGraph(executor.getCustomTableEnvironment(), jarsUrl);
264264
if (pipeline instanceof StreamGraph) {
265265
// stream job

dinky-client/dinky-client-base/src/main/java/org/dinky/url/RsURLStreamHandlerFactory.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.dinky.url;
2121

22+
import java.net.MalformedURLException;
2223
import java.net.URLStreamHandler;
2324
import java.net.URLStreamHandlerFactory;
2425
import java.util.Arrays;
@@ -28,15 +29,21 @@
2829

2930
public class RsURLStreamHandlerFactory implements URLStreamHandlerFactory {
3031
private static final String PREFIX = "sun.net.www.protocol";
31-
private final List<String> notContains = Arrays.asList("jar", "file", "http", "https");
3232

3333
@Override
3434
public URLStreamHandler createURLStreamHandler(String protocol) {
35-
for (String tempProtocol : notContains) {
36-
if (tempProtocol.equals(StrUtil.sub(protocol, 0, tempProtocol.length()))) {
37-
return null;
38-
}
35+
String name = PREFIX + "." + protocol + ".Handler";
36+
try {
37+
@SuppressWarnings("deprecation")
38+
Object o = Class.forName(name).newInstance();
39+
return (URLStreamHandler) o;
40+
} catch (ClassNotFoundException x) {
41+
// ignore
42+
} catch (Exception e) {
43+
// For compatibility, all Exceptions are ignored.
44+
// any number of exceptions can get thrown here
3945
}
46+
4047
if (ResourceFileSystem.URI_SCHEMA.getScheme().equals(protocol)) {
4148
return new RsURLStreamHandler();
4249
}
@@ -45,7 +52,6 @@ public URLStreamHandler createURLStreamHandler(String protocol) {
4552
} catch (Throwable e) {
4653
return null;
4754
}
48-
String name = PREFIX + "." + protocol + ".Handler";
4955
try {
5056
@SuppressWarnings("deprecation")
5157
Object o = Class.forName(name).newInstance();

dinky-metadata/dinky-metadata-paimon/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<dependency>
4040
<groupId>org.apache.paimon</groupId>
4141
<artifactId>paimon-bundle</artifactId>
42-
<version>0.8.1</version>
42+
<version>0.9.0</version>
4343
<scope>${scope.runtime}</scope>
4444
</dependency>
4545
<!-- https://mvnrepository.com/artifact/org.apache.paimon/paimon-s3 -->

0 commit comments

Comments
 (0)