Skip to content

Commit

Permalink
Upgrade to java 21 (LTS)
Browse files Browse the repository at this point in the history
* upgrade spring boot parent to 3.2.1
* upgrade to latest maven plugins
  • Loading branch information
camillokrausebarmanndmde committed Jan 10, 2024
1 parent 4c66b24 commit 30f43b8
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 60 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/run-with-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
java-version: '17'
java-version: '21'
distribution: 'adopt'
cache: maven

Expand Down
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2018 dmTECH GmbH, https://www.dmtech.de
Copyright (c) 2024 dmTECH GmbH, https://www.dmtech.de

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 1 addition & 2 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Marcus Fessele <[email protected]> (https://github.com/codeislyric)
Dominik Johs <[email protected]> (https://github.com/djohs)
Camillo Krause-Barmann <[email protected]> (https://github.com/Laksuh)
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ you will get the following measurements for every ```public``` method of the ```

## Runtime Dependencies

- Java >= 17
- Spring Boot >= 3.0.2
- Java >= 21
- Spring Boot >= 3.2.1

The library was compiled against:

- Spring Boot Acutator 3.0.2
- Spring Boot Acutator 3.2.1

## Installation
```
<dependency>
<groupId>de.dm.infrastructure</groupId>
<artifactId>micrometer-metrics-wrapper</artifactId>
<version>2.0.0</version>
<version>3.0.0</version>
</dependency>
```

The library contains all required dependencies, including [spring-boot-starter-actuator](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-project/spring-boot-actuator) v2.7.6.
The library contains all required dependencies, including [spring-boot-starter-actuator](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-project/spring-boot-actuator) v3.2.1.

## Usage

Expand Down Expand Up @@ -101,7 +101,7 @@ For every annotated class/method the library creates the following measurements:

# License

Copyright (c) 2018 dmTECH GmbH, https://www.dmtech.de
Copyright (c) 2024 dmTECH GmbH, https://www.dmtech.de

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 14 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>de.dm.infrastructure</groupId>
<artifactId>micrometer-metrics-wrapper</artifactId>
<version>2.0.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>

<name>micrometer-metrics-wrapper</name>
<description>Micrometer wrapper to allow generic class level metric values</description>
Expand All @@ -32,27 +32,33 @@
<name>Dominik Johs</name>
<email>[email protected]</email>
</developer>
<developer>
<organization>dmTECH GmbH</organization>
<organizationUrl>https://www.dmtech.de</organizationUrl>
<name>Camillo Krause genannt Barmann</name>
<email>[email protected]</email>
</developer>
</developers>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.2</version>
<version>3.2.1</version>
<relativePath/>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<java.version>17</java.version>
<java.version>21</java.version>

<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-javadoc-plugin.version.version>3.4.1</maven-javadoc-plugin.version.version>
<maven-release-plugin.version>3.0.1</maven-release-plugin.version>
<maven-source-plugin.version>3.3.0</maven-source-plugin.version>
<maven-javadoc-plugin.version.version>3.6.3</maven-javadoc-plugin.version.version>
<nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
<maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
<maven-gpg-plugin.version>3.1.0</maven-gpg-plugin.version>
<jacoco-maven-plugin.version>0.8.11</jacoco-maven-plugin.version>

<sonar.coverage.exclusions>**/*App.java,**/*Properties.java</sonar.coverage.exclusions>
</properties>
Expand Down
28 changes: 4 additions & 24 deletions src/main/java/de/dm/infrastructure/metrics/aop/MetricUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ private static Metric synthesizeAnnotation(Method method, Object target) {
.filter(StringUtils::hasText)
.orElse(method.getName());

String metricName = new StringBuilder()
.append(wrapName(StringUtils.uncapitalize(classKey)))
.append(StringUtils.uncapitalize(methodKey))
.toString();
String metricName = wrapName(StringUtils.uncapitalize(classKey)) +
StringUtils.uncapitalize(methodKey);
attributeMap.put("name", metricName);
return AnnotationUtils.synthesizeAnnotation(attributeMap, Metric.class, method);
}
Expand All @@ -65,34 +63,16 @@ private static String getClassName(Method method) {
return method.getDeclaringClass().getSimpleName();
}

/**
* Copy of {@link org.springframework.core.annotation.AnnotationUtils.AnnotationCacheKey}
*/
private static class AnnotationCacheKey {

private final AnnotatedElement element;

private final Class<? extends Annotation> annotationType;

AnnotationCacheKey(AnnotatedElement element, Class<? extends Annotation> annotationType) {
this.element = element;
this.annotationType = annotationType;
}

@Override
public int hashCode() {
return (this.element.hashCode() * 29 + this.annotationType.hashCode());
}
private record AnnotationCacheKey(AnnotatedElement element, Class<? extends Annotation> annotationType) {

@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AnnotationCacheKey)) {
if (!(other instanceof AnnotationCacheKey otherKey)) {
return false;
}
AnnotationCacheKey otherKey = (AnnotationCacheKey) other;
return (this.element.equals(otherKey.element) && this.annotationType.equals(otherKey.annotationType));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.core.instrument.config.NamingConvention;
import org.springframework.lang.NonNull;

/**
* Generic Metrics that only binds a {@link MeterRegistry} that we can use later
Expand All @@ -13,7 +14,7 @@ public class GenericClassMethodMetrics implements MeterBinder {
private MeterRegistry registry;

@Override
public void bindTo(MeterRegistry registry) {
public void bindTo(@NonNull MeterRegistry registry) {

this.registry = registry;
this.registry.config().namingConvention(NamingConvention.dot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.springframework.aop.Advisor;
import org.springframework.aop.aspectj.annotation.AspectJProxyFactory;

import java.lang.reflect.InvocationTargetException;

public class SetupUtil {

private static <T> T createProxy(Advisor advisor, Object noProxy) {
Expand All @@ -11,8 +13,8 @@ private static <T> T createProxy(Advisor advisor, Object noProxy) {
return factory.getProxy();
}

public static <T> T setUpAdvisedClass(Class<T> clazz, Advisor advisor) throws IllegalAccessException, InstantiationException {
T noProxy = clazz.newInstance();
public static <T> T setUpAdvisedClass(Class<T> clazz, Advisor advisor) throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
T noProxy = clazz.getDeclaredConstructor().newInstance();
return createProxy(advisor, noProxy);
}
}

0 comments on commit 30f43b8

Please sign in to comment.