Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #224 from Z-Jais/master
Browse files Browse the repository at this point in the history
Update dependencies and migrate to Java 21
  • Loading branch information
Ziedelth authored Nov 29, 2023
2 parents ccf6914 + 410fcb5 commit 2097c1a
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 19 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: 'adopt'

- name: Tests
Expand All @@ -28,10 +28,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: 'adopt'

- name: Build
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: 'adopt'

- name: Tests
Expand All @@ -31,10 +31,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: 'adopt'

- name: Build
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ COPY --from=build /app/target/api-1.0.0-jar-with-dependencies.jar /app/api.jar
COPY --from=build /app/data/ /app/data/

RUN apk update && apk add gcompat opencv-dev && rm -rf /var/cache/apk/*
RUN apk add --update ttf-dejavu && rm -rf /var/cache/apk/*
EXPOSE 8080
WORKDIR /app
ENTRYPOINT ["java", "-jar", "api.jar"]
ENTRYPOINT ["java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseG1GC", "-XX:G1NewSizePercent=20", "-XX:G1ReservePercent=20", "-XX:MaxGCPauseMillis=50", "-XX:G1HeapRegionSize=32M", "-jar", "api.jar"]
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
<properties>
<ktor_version>2.3.6</ktor_version>
<kotlin.code.style>official</kotlin.code.style>
<kotlin.version>1.9.20</kotlin.version>
<kotlin.version>1.9.21</kotlin.version>
<kotlin.compiler.languageVersion>2.0</kotlin.compiler.languageVersion>
<kotlin.compiler.jvmTarget>17</kotlin.compiler.jvmTarget>
<logback_version>1.4.11</logback_version>
<kotlin.compiler.jvmTarget>21</kotlin.compiler.jvmTarget>
<logback_version>1.4.13</logback_version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
<main.class>fr.ziedelth.ApplicationKt</main.class>
<junit-jupiter.version>5.10.1</junit-jupiter.version>
<hibernate.version>6.3.1.Final</hibernate.version>
<hibernate.version>6.4.0.Final</hibernate.version>

<sonar.coverage.exclusions>
**/fr/ziedelth/dtos/**,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import java.io.Serializable
import java.lang.reflect.ParameterizedType
import java.util.*

const val UNKNOWN_MESSAGE_ERROR = "Unknown error"
const val MISSING_PARAMETERS_MESSAGE_ERROR = "Missing parameters"

open class AbstractController<T : Serializable>(open val prefix: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ open class AbstractRepository<T> {
return database.inReadOnlyTransaction {
database.fullInitialize(
it.createQuery("FROM $entityName WHERE uuid IN :uuids", entityClass)
.setParameter("uuids", uuids)
.setParameter("uuids", uuids)
.resultList
)
}
Expand Down
26 changes: 22 additions & 4 deletions src/main/kotlin/fr/ziedelth/utils/ImageCache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,30 @@ import org.opencv.core.MatOfByte
import org.opencv.core.MatOfInt
import org.opencv.imgcodecs.Imgcodecs
import java.io.InputStream
import java.net.URL
import java.net.URI
import java.nio.file.Files
import java.util.*

object ImageCache {
data class Image(val url: String, val bytes: ByteArray = byteArrayOf(), val type: String = "jpg")
data class Image(val url: String, val bytes: ByteArray = byteArrayOf(), val type: String = "jpg") {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is Image) return false

if (url != other.url) return false
if (!bytes.contentEquals(other.bytes)) return false
if (type != other.type) return false

return true
}

override fun hashCode(): Int {
var result = url.hashCode()
result = 31 * result + bytes.contentHashCode()
result = 31 * result + type.hashCode()
return result
}
}

private val cache = mutableMapOf<UUID, Pair<Image, Boolean>>()

Expand Down Expand Up @@ -56,8 +74,8 @@ object ImageCache {
}
}

private fun saveImage(string: String?): InputStream {
val inputStream = URL(string).openStream()
private fun saveImage(string: String): InputStream {
val inputStream = URI(string).toURL().openStream()
val tmpFile = Files.createTempFile(UUID.randomUUID().toString(), ".jpg").toFile()
val outputStream = tmpFile.outputStream()
outputStream.use { inputStream.copyTo(it) }
Expand Down

0 comments on commit 2097c1a

Please sign in to comment.