Skip to content

Commit

Permalink
Fixes HTTP and HTTPS port binding in DEV mode (#9093)
Browse files Browse the repository at this point in the history
* Fixes HTTP and HTTPS port binding in DEV mode

* Formatting
  • Loading branch information
mkurz authored and octonato committed Apr 1, 2019
1 parent ea2e6da commit c34e72e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Expand Up @@ -291,7 +291,18 @@ object Reloader {

val server = {
val mainClass = applicationLoader.loadClass(mainClassName)
if (httpPort.isDefined) {
if (httpPort.isDefined && httpsPort.isDefined) {
val mainDev = mainClass.getMethod(
"mainDevHttpAndHttpsMode",
classOf[BuildLink],
classOf[Int],
classOf[Int],
classOf[String]
)
mainDev
.invoke(null, reloader, httpPort.get: java.lang.Integer, httpsPort.get: java.lang.Integer, httpAddress)
.asInstanceOf[play.core.server.ReloadableServer]
} else if (httpPort.isDefined) {
val mainDev = mainClass.getMethod("mainDevHttpMode", classOf[BuildLink], classOf[Int], classOf[String])
mainDev
.invoke(null, reloader, httpPort.get: java.lang.Integer, httpAddress)
Expand Down
Expand Up @@ -47,7 +47,22 @@ object DevServerStart {
* compiled with different versions of Scala.
*/
def mainDevHttpMode(buildLink: BuildLink, httpPort: Int, httpAddress: String): ReloadableServer = {
mainDev(buildLink, Some(httpPort), Option(System.getProperty("https.port")).map(Integer.parseInt), httpAddress)
mainDev(buildLink, Some(httpPort), None, httpAddress)
}

/**
* Provides an HTTP and HTTPS server for the dev environment
*
* <p>This method uses simple Java types so that it can be used with reflection by code
* compiled with different versions of Scala.
*/
def mainDevHttpAndHttpsMode(
buildLink: BuildLink,
httpPort: Int,
httpsPort: Int,
httpAddress: String
): ReloadableServer = {
mainDev(buildLink, Some(httpPort), Some(httpsPort), httpAddress)
}

private def mainDev(
Expand Down

0 comments on commit c34e72e

Please sign in to comment.