Skip to content

Commit f7569c7

Browse files
mkristiankares
authored andcommitted
search config.ru on context-classloader if not found otherwise
1 parent b9f325a commit f7569c7

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
package org.jruby.rack;
99

10-
import java.io.IOException;
10+
1111
import java.io.File;
12+
import java.io.IOException;
13+
import java.io.InputStream;
1214
import java.lang.reflect.InvocationTargetException;
1315
import java.lang.reflect.Method;
1416
import java.net.URISyntaxException;
@@ -531,15 +533,21 @@ private String resolveRackupScript() throws RackInitializationException {
531533
}
532534
}
533535

534-
if (rackup != null) {
535-
rackupLocation = rackContext.getRealPath(rackup);
536-
try {
537-
rackup = IOHelpers.inputStreamToString(rackContext.getResourceAsStream(rackup));
536+
InputStream is = null;
537+
try {
538+
if (rackup != null) {
539+
is = rackContext.getResourceAsStream(rackup);
540+
rackupLocation = rackContext.getRealPath(rackup);
538541
}
539-
catch (IOException e) {
540-
rackContext.log(RackLogger.ERROR, "failed to read rackup from '"+ rackup + "' (" + e + ")");
541-
throw new RackInitializationException("failed to read rackup input", e);
542+
else {
543+
is = Thread.currentThread().getContextClassLoader().getResourceAsStream("config.ru");
544+
rackupLocation = "uri:classloader://config.ru";
542545
}
546+
rackup = IOHelpers.inputStreamToString(is);
547+
}
548+
catch (IOException e) {
549+
rackContext.log(RackLogger.ERROR, "failed to read rackup from '"+ rackup + "' (" + e + ")");
550+
throw new RackInitializationException("failed to read rackup input", e);
543551
}
544552
}
545553

0 commit comments

Comments
 (0)