Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Java 17 #917

Merged
merged 14 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '13' ]
scala: [ '2.13.8' ]
java: [ '17' ]
scala: [ '2.13.11' ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK
Expand All @@ -25,4 +25,4 @@ jobs:
- name: Build
run: |
docker run -d -p 127.0.0.1:5432:5432 flowcommerce/apibuilder-postgresql:latest
sbt ++${{ matrix.scala }} clean coverage test coverageReport
sbt ++${{ matrix.scala }} clean test
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
before_script:
- docker run -d -p 127.0.0.1:7659:5432 flowcommerce/apibuilder-postgresql:latest
script:
- sbt ++$TRAVIS_SCALA_VERSION clean compile test
- CONF_APIBUILDER_API_HOST=http://localhost:9001 sbt ++$TRAVIS_SCALA_VERSION clean compile test
branches:
only:
- main
Expand Down
4 changes: 2 additions & 2 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM flowdocker/play_builder:latest-java13 as builder
FROM flowdocker/play_builder:latest-java17 as builder
ADD . /opt/play
WORKDIR /opt/play
RUN sbt 'project api' clean stage

FROM flowdocker/play:latest-java13
FROM flowdocker/play:latest-java17
COPY --from=builder /opt/play /opt/play
WORKDIR /opt/play/api/target/universal/stage
ENTRYPOINT ["java", "-jar", "/root/environment-provider.jar", "--service", "play", "apibuilder-api", "bin/apibuilder-api"]
Expand Down
6 changes: 2 additions & 4 deletions api/app/actors/EmailActor.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package actors

import akka.actor.{ActorLogging, ActorSystem}
import akka.actor.{Actor, ActorLogging, ActorSystem}
import db._
import io.apibuilder.api.v0.models.Publication
import lib.{AppConfig, Email, Person, Role}
import akka.actor.Actor

import java.util.UUID

object EmailActor {
Expand Down Expand Up @@ -36,8 +36,6 @@ class EmailActor @javax.inject.Inject() (
usersDao: UsersDao
) extends Actor with ActorLogging with ErrorHandler {

private[this] implicit val ec = system.dispatchers.lookup("email-actor-context")

def receive = {

case m @ EmailActor.Messages.MembershipRequestCreated(guid) => withVerboseErrorHandler(m) {
Expand Down
2 changes: 1 addition & 1 deletion api/app/actors/GeneratorServiceActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GeneratorServiceActor @javax.inject.Inject() (
processor: GeneratorServiceActorProcessor,
) extends Actor with ActorLogging with ErrorHandler {

private[this] implicit val ec = system.dispatchers.lookup("generator-service-actor-context")
private[this] implicit val ec: ExecutionContext = system.dispatchers.lookup("generator-service-actor-context")

system.scheduler.scheduleAtFixedRate(1.hour, 1.hour, self, GeneratorServiceActorMessage.SyncAll)

Expand Down
4 changes: 2 additions & 2 deletions api/app/actors/MainActor.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package actors

import java.util.UUID

import akka.actor._
import db.VersionsDao
import lib.Role
import play.api.Mode

import scala.concurrent.ExecutionContext
import scala.concurrent.duration.{FiniteDuration, SECONDS}
import scala.util.{Failure, Success, Try}

Expand Down Expand Up @@ -39,7 +39,7 @@ class MainActor @javax.inject.Inject() (
@javax.inject.Named("user-actor") userActor: akka.actor.ActorRef
) extends Actor with ActorLogging with ErrorHandler {

private[this] implicit val ec = system.dispatchers.lookup("main-actor-context")
private[this] implicit val ec: ExecutionContext = system.dispatchers.lookup("main-actor-context")

private[this] case object Startup

Expand Down
15 changes: 6 additions & 9 deletions api/app/actors/UserActor.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package actors

import akka.actor.{Actor, ActorLogging, ActorSystem}
import db.{EmailVerificationsDao, MembershipRequestsDao, OrganizationsDao, UsersDao}
import lib.Role
import play.api.Logger
import akka.actor.{Actor, ActorLogging}
import db.UsersDao

import java.util.UUID
import javax.inject.{Inject, Singleton}

object UserActor {

Expand All @@ -14,14 +14,11 @@ object UserActor {

}

@javax.inject.Singleton
class UserActor @javax.inject.Inject() (
system: ActorSystem,
@Singleton
class UserActor @Inject() (
usersDao: UsersDao
) extends Actor with ActorLogging with ErrorHandler {

private[this] implicit val ec = system.dispatchers.lookup("user-actor-context")

def receive = {

case m @ UserActor.Messages.UserCreated(guid) => withVerboseErrorHandler(m) {
Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/MembershipRequests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MembershipRequests @Inject() (

object MembershipRequestForm {

implicit val membershipRequestFormReads = Json.reads[MembershipRequestForm]
private[controllers] implicit val membershipRequestFormReads: Reads[MembershipRequestForm] = Json.reads[MembershipRequestForm]

}

Expand Down
9 changes: 5 additions & 4 deletions api/app/controllers/Users.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import io.apibuilder.api.v0.models.json._
import lib.Validation
import util.SessionHelper
import db.{UserPasswordsDao, UsersDao}

import javax.inject.Inject
import play.api.libs.json.{JsArray, JsBoolean, JsError, JsObject, JsString, JsSuccess, Json, Reads}

import play.api.libs.json.{JsArray, JsBoolean, JsError, JsObject, JsString, JsSuccess, Json}
import java.util.UUID

import play.api.libs.ws.WSClient

import scala.concurrent.Future

class Users @Inject() (
Expand All @@ -24,10 +25,10 @@ class Users @Inject() (
import scala.concurrent.ExecutionContext.Implicits.global

private[this] case class UserAuthenticationForm(email: String, password: String)
private[this] implicit val userAuthenticationFormReads = Json.reads[UserAuthenticationForm]
private[this] implicit val userAuthenticationFormReads: Reads[UserAuthenticationForm] = Json.reads[UserAuthenticationForm]

private[this] case class GithubAuthenticationForm(token: String)
private[this] implicit val githubAuthenticationFormReads = Json.reads[GithubAuthenticationForm]
private[this] implicit val githubAuthenticationFormReads: Reads[GithubAuthenticationForm] = Json.reads[GithubAuthenticationForm]

def get(
guid: Option[UUID],
Expand Down
2 changes: 0 additions & 2 deletions api/app/lib/AppConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class AppConfig @Inject() (

val apibuilderWwwHost: String = config.requiredString("apibuilder.app.host")

val apibuilderVersion: String = config.requiredString("git.version")

val subjectPrefix: String = config.requiredString("mail.subjectPrefix")

val emailDefaultFromEmail: String = config.requiredString("mail.defaultFromEmail")
Expand Down
1 change: 0 additions & 1 deletion api/app/util/UserAgent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class UserAgent @Inject() (
): String = {
Seq(
"apibuilder",
appConfig.apibuilderVersion,
Seq(
Some("https://" + appConfig.apibuilderWwwHost),
Some(orgKey),
Expand Down
3 changes: 3 additions & 0 deletions api/conf/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include "devandtest.conf"

play.modules.enabled += "modules.ProductionClientModule"
13 changes: 2 additions & 11 deletions api/conf/application.test.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
include "base.conf"
include "devandtest.conf"

db.default.url="jdbc:postgresql://localhost/apibuilderdb"
db.default.url=${?CONF_DB_DEFAULT_URL}

apibuilder.app.host="http://localhost:9000"

play.http.secret.key="development:uauTKwTxIpP4dWJA53s1ekGwpPdVfUmdCmSMgxa4"

mail.localDeliveryDir="/tmp/email.apibuilder"

play.modules.enabled += "modules.TestClientModule"
play.modules.enabled += "modules.TestClientModule"
6 changes: 2 additions & 4 deletions api/conf/base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ play.http.requestHandler = "play.http.DefaultHttpRequestHandler"
play.modules.enabled += "actors.ActorsModule"
play.modules.enabled += "io.flow.play.clients.ConfigModule"

mail.defaultFromEmail="mbryzek@alum.mit.edu"
mail.defaultFromEmail="mbryzek@gmail.com"
mail.defaultFromName="apibuilder"
mail.subjectPrefix="[apibuilder]"

# Space separate list of email addresses
apibuilder.sendErrorsTo="[email protected]"

git.version=0.15.33
apibuilder.sendErrorsTo="[email protected]"

akka {
actor {
Expand Down
11 changes: 11 additions & 0 deletions api/conf/devandtest.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include "base.conf"

db.default.url="jdbc:postgresql://localhost/apibuilderdb"
db.default.url=${?CONF_DB_DEFAULT_URL}

apibuilder.app.host="http://localhost:9000"

play.http.secret.key="development:uauTKwTxIpP4dWJA53s1ekGwpPdVfUmdCmSMgxa4"

mail.localDeliveryDir="/tmp/email.apibuilder"

6 changes: 3 additions & 3 deletions api/test/util/UserAgentSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ class UserAgentSpec extends PlaySpec with GuiceOneAppPerSuite {
applicationKey = "apibuilder",
versionName = "1.2.3",
generatorKey = Some("play_client")
) must fullyMatch regex("apibuilder 0\\.[0-9]+\\.[0-9]+ localhost 9000/apicollective/apibuilder/1\\.2\\.3/play_client")
) must fullyMatch regex("apibuilder localhost 9000/apicollective/apibuilder/1\\.2\\.3/play_client")

userAgent.generate(
orgKey = "apicollective",
applicationKey = "apibuilder",
versionName = "1:0",
generatorKey = Some("play_client")
) must fullyMatch regex("apibuilder 0\\.[0-9]+\\.[0-9]+ localhost 9000/apicollective/apibuilder/1 0/play_client")
) must fullyMatch regex("apibuilder localhost 9000/apicollective/apibuilder/1 0/play_client")

userAgent.generate(
orgKey = "apicollective",
applicationKey = "apibuilder",
versionName = "1:0",
generatorKey = None
) must fullyMatch regex("apibuilder 0\\.[0-9]+\\.[0-9]+ localhost 9000/apicollective/apibuilder/1 0")
) must fullyMatch regex("apibuilder localhost 9000/apicollective/apibuilder/1 0")
}

}
4 changes: 2 additions & 2 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM flowdocker/play_builder:latest-java13 as builder
FROM flowdocker/play_builder:latest-java17 as builder
ADD . /opt/play
WORKDIR /opt/play
RUN sbt 'project app' clean stage

FROM flowdocker/play:latest-java13
FROM flowdocker/play:latest-java17
COPY --from=builder /opt/play /opt/play
WORKDIR /opt/play/app/target/universal/stage
ENTRYPOINT ["java", "-jar", "/root/environment-provider.jar", "--service", "play", "apibuilder-app", "bin/apibuilder-app"]
Expand Down
3 changes: 2 additions & 1 deletion app/app/controllers/AccountController.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package controllers

import javax.inject.Inject
import scala.concurrent.ExecutionContext

class AccountController @Inject() (
val apiBuilderControllerComponents: ApiBuilderControllerComponents
) extends ApiBuilderController {

private[this] implicit val ec = scala.concurrent.ExecutionContext.Implicits.global
private[this] implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global

def redirect = Action { implicit request =>
Redirect(routes.AccountController.index())
Expand Down
6 changes: 3 additions & 3 deletions app/app/controllers/AccountProfileController.scala
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package controllers

import io.apibuilder.api.v0.models.UserUpdateForm
import javax.inject.Inject

import javax.inject.Inject
import play.api.data._
import play.api.data.Forms._

import scala.concurrent.Future
import scala.concurrent.{ExecutionContext, Future}

class AccountProfileController @Inject() (
val apiBuilderControllerComponents: ApiBuilderControllerComponents
) extends ApiBuilderController {

private[this] implicit val ec = scala.concurrent.ExecutionContext.Implicits.global
private[this] implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global

def redirect = Action { implicit request =>
Redirect(routes.AccountProfileController.index())
Expand Down
4 changes: 3 additions & 1 deletion app/app/controllers/ApplicationController.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package controllers

import lib.{ApiClientProvider, PaginatedCollection, Pagination}

import javax.inject.Inject
import scala.concurrent.ExecutionContext

class ApplicationController @Inject() (
val apiBuilderControllerComponents: ApiBuilderControllerComponents,
apiClientProvider: ApiClientProvider
) extends ApiBuilderController {

private[this] implicit val ec = scala.concurrent.ExecutionContext.Implicits.global
private[this] implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global

def redirect() = Action { request =>
Redirect(request.path + "/")
Expand Down
5 changes: 3 additions & 2 deletions app/app/controllers/ApplicationSettings.scala
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package controllers

import io.apibuilder.api.v0.models.{ApplicationForm, MoveForm, Visibility}

import javax.inject.Inject
import lib.ApiClientProvider
import models._
import play.api.data.Forms._
import play.api.data._
import play.api.mvc.Result

import scala.concurrent.Future
import scala.concurrent.{ExecutionContext, Future}

class ApplicationSettings @Inject() (
val apiBuilderControllerComponents: ApiBuilderControllerComponents,
apiClientProvider: ApiClientProvider
) extends ApiBuilderController {

private[this] implicit val ec = scala.concurrent.ExecutionContext.Implicits.global
private[this] implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global

private[this] def withRedirect(
result: Either[String, MainTemplate]
Expand Down
5 changes: 2 additions & 3 deletions app/app/controllers/AttributesController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package controllers
import io.apibuilder.api.v0.models.AttributeForm
import lib.{ApiClientProvider, PaginatedCollection, Pagination}

import scala.concurrent.Future
import scala.concurrent.{ExecutionContext, Future}
import javax.inject.Inject

import play.api.data.Forms._
import play.api.data._

Expand All @@ -14,7 +13,7 @@ class AttributesController @Inject() (
apiClientProvider: ApiClientProvider
) extends ApiBuilderController {

private[this] implicit val ec = scala.concurrent.ExecutionContext.Implicits.global
private[this] implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global

def index(page: Int = 0) = Anonymous.async { implicit request =>
for {
Expand Down
4 changes: 2 additions & 2 deletions app/app/controllers/Domains.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import models._
import play.api.data._
import play.api.data.Forms._

import scala.concurrent.Future
import scala.concurrent.{ExecutionContext, Future}
import javax.inject.Inject

class Domains @Inject() (
val apiBuilderControllerComponents: ApiBuilderControllerComponents,
apiClientProvider: ApiClientProvider
) extends ApiBuilderController {

private[this] implicit val ec = scala.concurrent.ExecutionContext.Implicits.global
private[this] implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global

def index(orgKey: String) = IdentifiedOrg { implicit request =>
request.withMember {
Expand Down
Loading