Skip to content

Commit

Permalink
Update to Java 17
Browse files Browse the repository at this point in the history
  • Loading branch information
jacomago committed Nov 24, 2023
1 parent 9b7751d commit 40a8ac6
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 104 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
- uses: ankane/setup-elasticsearch@v1
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
Expand All @@ -39,10 +39,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Test with Maven
Expand All @@ -59,10 +59,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
- uses: ankane/setup-elasticsearch@v1
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM openjdk:11-jre
FROM openjdk:17-jre
WORKDIR /channelfinder
ADD https://repo1.maven.org/maven2/org/phoebus/app-channel-channelfinder/4.7.2/app-channel-channelfinder-4.7.2.jar .
2 changes: 1 addition & 1 deletion Dockerfile.integrationtest
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# ------------------------------------------------------------------------------

FROM openjdk:11
FROM openjdk:17

# deployment unit
COPY target/ChannelFinder-*.jar /channelfinder/ChannelFinder-*.jar
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Collected installation recipes and notes may be found on [wiki pages](https://gi

* Prerequisites

* JDK 11
* JDK 17
* Elastic version 8.2.x
* <For authN/authZ using LDAP:> LDAP server, e.g. OpenLDAP

Expand All @@ -45,7 +45,7 @@ Collected installation recipes and notes may be found on [wiki pages](https://gi
* Build
```
# Debian 10
sudo apt-get install openjdk-11-jdk maven git curl wget
sudo apt-get install openjdk-17-jdk maven git curl wget
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.2.0-amd64.deb
sudo dpkg -i elasticsearch-8.2.0-amd64.deb
sudo systemctl start elasticsearch
Expand Down
29 changes: 3 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,6 @@
</dependencies>
</dependencyManagement>
<dependencies>
<!-- The following 3 dependencies are temporarily added for java 11 compatibility
TODO They should be removed as soon as possible. -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
<!-- The above 3 dependencies are temporarily added for java 11 compatibility -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
Expand All @@ -85,11 +67,6 @@
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!--JUnit Jupiter Engine to depend on the JUnit5 engine and JUnit 5 API -->
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down Expand Up @@ -345,8 +322,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>11</source>
<target>11</target>
<source>17</source>
<target>17</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
Expand Down Expand Up @@ -422,7 +399,7 @@
<additionalOptions>
<additionalOption>-Xdoclint:none</additionalOption>
</additionalOptions>
<source>11</source>
<source>17</source>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class ChannelManager {
*/
@GetMapping
public List<Channel> query(@RequestParam MultiValueMap<String, String> allRequestParams) {
return channelRepository.search(allRequestParams).getChannels();
return channelRepository.search(allRequestParams).channels();
}

@GetMapping("/combined")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public Optional<Property> findById(String propertyName, boolean withChannels) {
if(withChannels) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add(property.getName(), "*");
property.setChannels(channelRepository.search(params).getChannels());
property.setChannels(channelRepository.search(params).channels());
}
return Optional.of(property);
} else {
Expand Down Expand Up @@ -330,7 +330,7 @@ public void deleteById(String propertyName) {
BulkRequest.Builder br = new BulkRequest.Builder().refresh(Refresh.True);
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add(propertyName, "*");
List<Channel> channels = channelRepository.search(params).getChannels();
List<Channel> channels = channelRepository.search(params).channels();
while (channels.size() > 0) {
for (Channel channel : channels) {
channel.removeProperty(
Expand Down Expand Up @@ -360,7 +360,7 @@ public void deleteById(String propertyName) {

}
params.set("~search_after", channels.get(channels.size() - 1).getName());
channels = channelRepository.search(params).getChannels();
channels = channelRepository.search(params).channels();
}
} catch (ElasticsearchException | IOException e) {
String message = MessageFormat.format(TextUtil.FAILED_TO_DELETE_PROPERTY, propertyName);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/phoebus/channelfinder/TagRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public Optional<Tag> findById(String tagId, boolean withChannels) {
if(withChannels) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("~tag", tag.getName());
tag.setChannels(channelRepository.search(params).getChannels());
tag.setChannels(channelRepository.search(params).channels());
}
return Optional.of(tag);
} else {
Expand Down Expand Up @@ -329,7 +329,7 @@ public void deleteById(String tagName) {
BulkRequest.Builder br = new BulkRequest.Builder().refresh(Refresh.True);
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("~tag", tagName);
List<Channel> channels = channelRepository.search(params).getChannels();
List<Channel> channels = channelRepository.search(params).channels();
while (channels.size() > 0) {

for (Channel channel : channels) {
Expand Down Expand Up @@ -366,7 +366,7 @@ public void deleteById(String tagName) {

}
params.set("~search_after", channels.get(channels.size() - 1).getName());
channels = channelRepository.search(params).getChannels();
channels = channelRepository.search(params).channels();
}

} catch (ElasticsearchException | IOException e) {
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/org/phoebus/channelfinder/entity/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
* All rights reserved. Use is subject to license terms.
* #L%
*/

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -22,8 +19,6 @@
* @author Ralph Lange {@literal <ralph.lange@gmx.de>}
*/

@XmlRootElement(name="channel")
@XmlType (propOrder={"name","owner","properties","tags"})
public class Channel {
private String name;
private String owner;
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/org/phoebus/channelfinder/entity/Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -22,8 +20,6 @@
*
* @author Ralph Lange {@literal <ralph.lange@gmx.de>}
*/
@XmlRootElement(name="property")
@XmlType (propOrder={"name","owner","value","channels"})
public class Property {
private String name;
private String owner;
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/org/phoebus/channelfinder/entity/Scroll.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlRootElement(name="scroll")
@XmlType (propOrder={"id","channels"})
public class Scroll {
private String id;
private List<Channel> channels = new ArrayList<>();
Expand Down
38 changes: 12 additions & 26 deletions src/main/java/org/phoebus/channelfinder/entity/SearchResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@

import java.util.List;

public class SearchResult {
private final long count;
private final List<Channel> channels;
public SearchResult(List<Channel> channels, long count) {
this.channels = channels;
this.count = count;
}
public record SearchResult(List<Channel> channels, long count) {

@Override
public String toString() {
Expand All @@ -21,25 +15,17 @@ public String toString() {
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SearchResult that = (SearchResult) o;
return count == that.count && Objects.equal(channels, that.channels);
}

@Override
public int hashCode() {
return Objects.hashCode(count, channels);
}

public long getCount() {
return count;
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SearchResult that = (SearchResult) o;
return count == that.count && Objects.equal(channels, that.channels);
}

public List<Channel> getChannels() {
return channels;
}
@Override
public int hashCode() {
return Objects.hashCode(count, channels);
}


}
}
4 changes: 0 additions & 4 deletions src/main/java/org/phoebus/channelfinder/entity/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -23,8 +21,6 @@
*
* @author Ralph Lange {@literal <ralph.lange@gmx.de>}
*/
@XmlRootElement(name="tag")
@XmlType (propOrder={"name","owner","channels"})
public class Tag {
private String name;
private String owner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void run() {
}
}

List<Channel> result = channelRepository.search(searchParameters).getChannels();
List<Channel> result = channelRepository.search(searchParameters).channels();

final Map<String, List<String>> channelTable = new HashMap<>();
final Map<String, List<String>> channelPropertyTable = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ void searchTest() {
searchParameters.add("~name", channelNames.get(0));
SearchResult result = channelRepository.search(searchParameters);
long countResult = channelRepository.count(searchParameters);
Assertions.assertEquals(1, result.getCount());
Assertions.assertEquals(1, result.getChannels().size());
Assertions.assertEquals(1, result.count());
Assertions.assertEquals(1, result.channels().size());
Assertions.assertEquals(1, countResult);
Assertions.assertEquals(result.getChannels().get(0).getName(), channelNames.get(0));
Assertions.assertEquals(result.channels().get(0).getName(), channelNames.get(0));

logger.log(Level.INFO, "Search for all channels via wildcards");
searchName(2, "BR:C001-BI:2{BLA}Pos:?-RB");
Expand Down Expand Up @@ -142,8 +142,8 @@ private void assertSearchCount(long expectedResultCount, int expectedChannelsCou
long countResult = channelRepository.count(searchParameters);

// Assert
Assertions.assertEquals(expectedResultCount, result.getCount());
Assertions.assertEquals(expectedChannelsCount, result.getChannels().size());
Assertions.assertEquals(expectedResultCount, result.count());
Assertions.assertEquals(expectedChannelsCount, result.channels().size());
Assertions.assertEquals(expectedQueryCount, countResult);
}

Expand All @@ -156,7 +156,7 @@ private void checkGroup(int bucket, String key, String value) {
SearchResult result = channelRepository.search(searchParameters);
long countResult = channelRepository.count(searchParameters);
Integer expectedCount = CELLS * bucket;
Assertions.assertEquals(expectedCount, Integer.valueOf(result.getChannels().size()), "Search: " + maptoString(searchParameters));
Assertions.assertEquals(expectedCount, Integer.valueOf(result.channels().size()), "Search: " + maptoString(searchParameters));
Assertions.assertEquals(expectedCount, Integer.valueOf((int) countResult));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void createXmlPropertiesWithOverride() {
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
params.add("testProperty0WithChannels", "*");
// verify the property was removed from the old channels
Assertions.assertEquals(Arrays.asList(testChannels.get(1)), channelRepository.search(params).getChannels(), "Failed to delete the property from channels");
Assertions.assertEquals(Arrays.asList(testChannels.get(1)), channelRepository.search(params).channels(), "Failed to delete the property from channels");
}

/**
Expand Down Expand Up @@ -736,7 +736,7 @@ void deleteXmlProperty() {
params.add("testProperty0WithChannels", "*");
// verify the property was deleted and removed from all associated channels
Assertions.assertFalse(propertyRepository.existsById(testProperty0WithChannels.getName()), "Failed to delete the property");
Assertions.assertEquals(new ArrayList<Channel>(), channelRepository.search(params).getChannels(), "Failed to delete the property from channels");
Assertions.assertEquals(new ArrayList<Channel>(), channelRepository.search(params).channels(), "Failed to delete the property from channels");
}

/**
Expand All @@ -757,7 +757,7 @@ void deleteXmlPropertyFromChannel() {
// Verify the property is removed from the testChannel0
MultiValueMap<String, String> searchParameters = new LinkedMultiValueMap<String, String>();
searchParameters.add("testProperty0WithChannels", "*");
Assertions.assertFalse(channelRepository.search(searchParameters).getChannels().stream().anyMatch(ch -> {
Assertions.assertFalse(channelRepository.search(searchParameters).channels().stream().anyMatch(ch -> {
return ch.getName().equals(testChannel0.getName());
}), "Failed to delete the property from channel");
}
Expand Down
Loading

0 comments on commit 40a8ac6

Please sign in to comment.