Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
f918e0eb
Commit
f918e0eb
authored
Mar 05, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
85900796
eee891db
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
9 deletions
+25
-9
PropertiesLauncher.java
...a/org/springframework/boot/loader/PropertiesLauncher.java
+14
-9
PropertiesLauncherTests.java
.../springframework/boot/loader/PropertiesLauncherTests.java
+11
-0
No files found.
spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java
View file @
f918e0eb
...
@@ -20,9 +20,11 @@ import java.io.File;
...
@@ -20,9 +20,11 @@ import java.io.File;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.UnsupportedEncodingException
;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.net.URLConnection
;
import
java.net.URLDecoder
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.LinkedHashSet
;
import
java.util.LinkedHashSet
;
...
@@ -203,21 +205,24 @@ public class PropertiesLauncher extends Launcher {
...
@@ -203,21 +205,24 @@ public class PropertiesLauncher extends Launcher {
if
(
config
.
startsWith
(
"classpath:"
))
{
if
(
config
.
startsWith
(
"classpath:"
))
{
return
getClasspathResource
(
config
.
substring
(
"classpath:"
.
length
()));
return
getClasspathResource
(
config
.
substring
(
"classpath:"
.
length
()));
}
}
config
=
stripFileUrlPrefix
(
config
);
config
=
handleUrl
(
config
);
if
(
isUrl
(
config
))
{
if
(
isUrl
(
config
))
{
return
getURLResource
(
config
);
return
getURLResource
(
config
);
}
}
return
getFileResource
(
config
);
return
getFileResource
(
config
);
}
}
private
String
stripFileUrlPrefix
(
String
config
)
{
private
String
handleUrl
(
String
path
)
throws
UnsupportedEncodingException
{
if
(
config
.
startsWith
(
"file:"
))
{
if
(
path
.
startsWith
(
"jar:file:"
)
||
path
.
startsWith
(
"file:"
))
{
config
=
config
.
substring
(
"file:"
.
length
());
path
=
URLDecoder
.
decode
(
path
,
"UTF-8"
);
if
(
config
.
startsWith
(
"//"
))
{
if
(
path
.
startsWith
(
"file:"
))
{
config
=
config
.
substring
(
2
);
path
=
path
.
substring
(
"file:"
.
length
());
if
(
path
.
startsWith
(
"//"
))
{
path
=
path
.
substring
(
2
);
}
}
}
}
}
return
config
;
return
path
;
}
}
private
boolean
isUrl
(
String
config
)
{
private
boolean
isUrl
(
String
config
)
{
...
@@ -454,8 +459,8 @@ public class PropertiesLauncher extends Launcher {
...
@@ -454,8 +459,8 @@ public class PropertiesLauncher extends Launcher {
}
}
private
List
<
Archive
>
getClassPathArchives
(
String
path
)
throws
Exception
{
private
List
<
Archive
>
getClassPathArchives
(
String
path
)
throws
Exception
{
String
root
=
cleanupPath
(
stripFileUrlPrefix
(
path
));
String
root
=
cleanupPath
(
handleUrl
(
path
));
List
<
Archive
>
lib
=
new
ArrayList
<>();
List
<
Archive
>
lib
=
new
ArrayList
<
Archive
>();
File
file
=
new
File
(
root
);
File
file
=
new
File
(
root
);
if
(!
"/"
.
equals
(
root
))
{
if
(!
"/"
.
equals
(
root
))
{
if
(!
isAbsolutePath
(
root
))
{
if
(!
isAbsolutePath
(
root
))
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/PropertiesLauncherTests.java
View file @
f918e0eb
...
@@ -346,6 +346,17 @@ public class PropertiesLauncherTests {
...
@@ -346,6 +346,17 @@ public class PropertiesLauncherTests {
assertThat
(
launcher
.
getMainClass
()).
isEqualTo
(
"demo.FooApplication"
);
assertThat
(
launcher
.
getMainClass
()).
isEqualTo
(
"demo.FooApplication"
);
}
}
@Test
public
void
encodedFileUrlLoaderPathIsHandledCorrectly
()
throws
Exception
{
File
loaderPath
=
this
.
temporaryFolder
.
newFolder
(
"loader path"
);
System
.
setProperty
(
"loader.path"
,
loaderPath
.
toURI
().
toURL
().
toString
());
PropertiesLauncher
launcher
=
new
PropertiesLauncher
();
List
<
Archive
>
archives
=
launcher
.
getClassPathArchives
();
assertThat
(
archives
.
size
()).
isEqualTo
(
1
);
File
archiveRoot
=
(
File
)
ReflectionTestUtils
.
getField
(
archives
.
get
(
0
),
"root"
);
assertThat
(
archiveRoot
).
isEqualTo
(
loaderPath
);
}
private
void
waitFor
(
String
value
)
throws
Exception
{
private
void
waitFor
(
String
value
)
throws
Exception
{
int
count
=
0
;
int
count
=
0
;
boolean
timeout
=
false
;
boolean
timeout
=
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment