From 40a8ac6566c7d4fbac150235c8b9e81a7445a2ef Mon Sep 17 00:00:00 2001 From: Sky Brewer Date: Thu, 9 Nov 2023 11:02:17 +0100 Subject: [PATCH] Update to Java 17 --- .github/workflows/codecov.yml | 4 +- .github/workflows/maven.yml | 12 +++--- Dockerfile | 2 +- Dockerfile.integrationtest | 2 +- README.md | 4 +- pom.xml | 29 ++------------ .../phoebus/channelfinder/ChannelManager.java | 2 +- .../channelfinder/PropertyRepository.java | 6 +-- .../phoebus/channelfinder/TagRepository.java | 6 +-- .../phoebus/channelfinder/entity/Channel.java | 5 --- .../channelfinder/entity/Property.java | 4 -- .../phoebus/channelfinder/entity/Scroll.java | 5 --- .../channelfinder/entity/SearchResult.java | 38 ++++++------------- .../org/phoebus/channelfinder/entity/Tag.java | 4 -- .../epics/ChannelFinderEpicsService.java | 2 +- .../ChannelRepositorySearchIT.java | 12 +++--- .../channelfinder/PropertyManagerIT.java | 6 +-- .../channelfinder/PropertyRepositoryIT.java | 2 +- .../phoebus/channelfinder/TagManagerIT.java | 6 +-- .../channelfinder/TagRepositoryIT.java | 2 +- 20 files changed, 49 insertions(+), 104 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index f74a18b0..3f951d60 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -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 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 326daf2e..8d42f04e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -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 @@ -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 @@ -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 diff --git a/Dockerfile b/Dockerfile index 40320a0f..86f9a183 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 . diff --git a/Dockerfile.integrationtest b/Dockerfile.integrationtest index b79760f2..2874e08b 100644 --- a/Dockerfile.integrationtest +++ b/Dockerfile.integrationtest @@ -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 diff --git a/README.md b/README.md index 2057b43b..a34c2552 100644 --- a/README.md +++ b/README.md @@ -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 * LDAP server, e.g. OpenLDAP @@ -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 diff --git a/pom.xml b/pom.xml index 8fcf70d2..31a053aa 100644 --- a/pom.xml +++ b/pom.xml @@ -55,24 +55,6 @@ - - - javax.xml.bind - jaxb-api - 2.3.0 - - - com.sun.xml.bind - jaxb-core - 2.3.0 - - - com.sun.xml.bind - jaxb-impl - 2.3.0 - - org.springframework.boot spring-boot-starter @@ -85,11 +67,6 @@ org.springframework.data spring-data-commons - - javax.servlet - javax.servlet-api - provided - org.junit.jupiter @@ -345,8 +322,8 @@ maven-compiler-plugin 3.11.0 - 11 - 11 + 17 + 17 ${project.build.sourceEncoding} @@ -422,7 +399,7 @@ -Xdoclint:none - 11 + 17 diff --git a/src/main/java/org/phoebus/channelfinder/ChannelManager.java b/src/main/java/org/phoebus/channelfinder/ChannelManager.java index f6ee485d..36e75800 100644 --- a/src/main/java/org/phoebus/channelfinder/ChannelManager.java +++ b/src/main/java/org/phoebus/channelfinder/ChannelManager.java @@ -76,7 +76,7 @@ public class ChannelManager { */ @GetMapping public List query(@RequestParam MultiValueMap allRequestParams) { - return channelRepository.search(allRequestParams).getChannels(); + return channelRepository.search(allRequestParams).channels(); } @GetMapping("/combined") diff --git a/src/main/java/org/phoebus/channelfinder/PropertyRepository.java b/src/main/java/org/phoebus/channelfinder/PropertyRepository.java index 217bd81a..125f07c3 100644 --- a/src/main/java/org/phoebus/channelfinder/PropertyRepository.java +++ b/src/main/java/org/phoebus/channelfinder/PropertyRepository.java @@ -225,7 +225,7 @@ public Optional findById(String propertyName, boolean withChannels) { if(withChannels) { MultiValueMap params = new LinkedMultiValueMap<>(); params.add(property.getName(), "*"); - property.setChannels(channelRepository.search(params).getChannels()); + property.setChannels(channelRepository.search(params).channels()); } return Optional.of(property); } else { @@ -330,7 +330,7 @@ public void deleteById(String propertyName) { BulkRequest.Builder br = new BulkRequest.Builder().refresh(Refresh.True); MultiValueMap params = new LinkedMultiValueMap<>(); params.add(propertyName, "*"); - List channels = channelRepository.search(params).getChannels(); + List channels = channelRepository.search(params).channels(); while (channels.size() > 0) { for (Channel channel : channels) { channel.removeProperty( @@ -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); diff --git a/src/main/java/org/phoebus/channelfinder/TagRepository.java b/src/main/java/org/phoebus/channelfinder/TagRepository.java index b7dac3b1..bafe077c 100644 --- a/src/main/java/org/phoebus/channelfinder/TagRepository.java +++ b/src/main/java/org/phoebus/channelfinder/TagRepository.java @@ -226,7 +226,7 @@ public Optional findById(String tagId, boolean withChannels) { if(withChannels) { MultiValueMap 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 { @@ -329,7 +329,7 @@ public void deleteById(String tagName) { BulkRequest.Builder br = new BulkRequest.Builder().refresh(Refresh.True); MultiValueMap params = new LinkedMultiValueMap<>(); params.add("~tag", tagName); - List channels = channelRepository.search(params).getChannels(); + List channels = channelRepository.search(params).channels(); while (channels.size() > 0) { for (Channel channel : channels) { @@ -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) { diff --git a/src/main/java/org/phoebus/channelfinder/entity/Channel.java b/src/main/java/org/phoebus/channelfinder/entity/Channel.java index 87175c27..10d7f6a2 100644 --- a/src/main/java/org/phoebus/channelfinder/entity/Channel.java +++ b/src/main/java/org/phoebus/channelfinder/entity/Channel.java @@ -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; @@ -22,8 +19,6 @@ * @author Ralph Lange {@literal } */ -@XmlRootElement(name="channel") -@XmlType (propOrder={"name","owner","properties","tags"}) public class Channel { private String name; private String owner; diff --git a/src/main/java/org/phoebus/channelfinder/entity/Property.java b/src/main/java/org/phoebus/channelfinder/entity/Property.java index ad6f9fee..3be7ccaf 100644 --- a/src/main/java/org/phoebus/channelfinder/entity/Property.java +++ b/src/main/java/org/phoebus/channelfinder/entity/Property.java @@ -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; @@ -22,8 +20,6 @@ * * @author Ralph Lange {@literal } */ -@XmlRootElement(name="property") -@XmlType (propOrder={"name","owner","value","channels"}) public class Property { private String name; private String owner; diff --git a/src/main/java/org/phoebus/channelfinder/entity/Scroll.java b/src/main/java/org/phoebus/channelfinder/entity/Scroll.java index d2bf356b..51be0ae9 100644 --- a/src/main/java/org/phoebus/channelfinder/entity/Scroll.java +++ b/src/main/java/org/phoebus/channelfinder/entity/Scroll.java @@ -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 channels = new ArrayList<>(); diff --git a/src/main/java/org/phoebus/channelfinder/entity/SearchResult.java b/src/main/java/org/phoebus/channelfinder/entity/SearchResult.java index 343a627e..43ab51d3 100644 --- a/src/main/java/org/phoebus/channelfinder/entity/SearchResult.java +++ b/src/main/java/org/phoebus/channelfinder/entity/SearchResult.java @@ -4,13 +4,7 @@ import java.util.List; -public class SearchResult { - private final long count; - private final List channels; - public SearchResult(List channels, long count) { - this.channels = channels; - this.count = count; - } +public record SearchResult(List channels, long count) { @Override public String toString() { @@ -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 getChannels() { - return channels; - } + @Override + public int hashCode() { + return Objects.hashCode(count, channels); + } - } \ No newline at end of file +} \ No newline at end of file diff --git a/src/main/java/org/phoebus/channelfinder/entity/Tag.java b/src/main/java/org/phoebus/channelfinder/entity/Tag.java index 815d2c4e..ed2166b7 100644 --- a/src/main/java/org/phoebus/channelfinder/entity/Tag.java +++ b/src/main/java/org/phoebus/channelfinder/entity/Tag.java @@ -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; @@ -23,8 +21,6 @@ * * @author Ralph Lange {@literal } */ -@XmlRootElement(name="tag") -@XmlType (propOrder={"name","owner","channels"}) public class Tag { private String name; private String owner; diff --git a/src/main/java/org/phoebus/channelfinder/epics/ChannelFinderEpicsService.java b/src/main/java/org/phoebus/channelfinder/epics/ChannelFinderEpicsService.java index 1cdc1cd6..dd63d176 100644 --- a/src/main/java/org/phoebus/channelfinder/epics/ChannelFinderEpicsService.java +++ b/src/main/java/org/phoebus/channelfinder/epics/ChannelFinderEpicsService.java @@ -164,7 +164,7 @@ public void run() { } } - List result = channelRepository.search(searchParameters).getChannels(); + List result = channelRepository.search(searchParameters).channels(); final Map> channelTable = new HashMap<>(); final Map> channelPropertyTable = new HashMap<>(); diff --git a/src/test/java/org/phoebus/channelfinder/ChannelRepositorySearchIT.java b/src/test/java/org/phoebus/channelfinder/ChannelRepositorySearchIT.java index 853035a8..908ac587 100644 --- a/src/test/java/org/phoebus/channelfinder/ChannelRepositorySearchIT.java +++ b/src/test/java/org/phoebus/channelfinder/ChannelRepositorySearchIT.java @@ -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"); @@ -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); } @@ -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)); } diff --git a/src/test/java/org/phoebus/channelfinder/PropertyManagerIT.java b/src/test/java/org/phoebus/channelfinder/PropertyManagerIT.java index b0c45f89..28c32d73 100644 --- a/src/test/java/org/phoebus/channelfinder/PropertyManagerIT.java +++ b/src/test/java/org/phoebus/channelfinder/PropertyManagerIT.java @@ -330,7 +330,7 @@ void createXmlPropertiesWithOverride() { MultiValueMap params = new LinkedMultiValueMap(); 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"); } /** @@ -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(), channelRepository.search(params).getChannels(), "Failed to delete the property from channels"); + Assertions.assertEquals(new ArrayList(), channelRepository.search(params).channels(), "Failed to delete the property from channels"); } /** @@ -757,7 +757,7 @@ void deleteXmlPropertyFromChannel() { // Verify the property is removed from the testChannel0 MultiValueMap searchParameters = new LinkedMultiValueMap(); 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"); } diff --git a/src/test/java/org/phoebus/channelfinder/PropertyRepositoryIT.java b/src/test/java/org/phoebus/channelfinder/PropertyRepositoryIT.java index 970b14e0..130926e1 100644 --- a/src/test/java/org/phoebus/channelfinder/PropertyRepositoryIT.java +++ b/src/test/java/org/phoebus/channelfinder/PropertyRepositoryIT.java @@ -256,7 +256,7 @@ void deleteXmlProperty() { MultiValueMap params = new LinkedMultiValueMap(); params.add("testProperty","*"); - List chans = channelRepository.search(params).getChannels(); + List chans = channelRepository.search(params).channels(); // verify the property was deleted from channels as expected Assertions.assertTrue(chans.isEmpty(), "Failed to remove property from channel"); } diff --git a/src/test/java/org/phoebus/channelfinder/TagManagerIT.java b/src/test/java/org/phoebus/channelfinder/TagManagerIT.java index 0ab1ac68..03ffc52d 100644 --- a/src/test/java/org/phoebus/channelfinder/TagManagerIT.java +++ b/src/test/java/org/phoebus/channelfinder/TagManagerIT.java @@ -292,7 +292,7 @@ void createXmlTagsWithOverride() { MultiValueMap params = new LinkedMultiValueMap(); params.add("~tag", testTag0WithChannels.getName()); // verify the tag was removed from the old channels - Assertions.assertEquals(Arrays.asList(testChannel1), channelRepository.search(params).getChannels(), "Failed to change the channels the tag is attached to correctly"); + Assertions.assertEquals(Arrays.asList(testChannel1), channelRepository.search(params).channels(), "Failed to change the channels the tag is attached to correctly"); } /** @@ -628,7 +628,7 @@ void deleteXmlTag() { params.add("~tag", testTag1.getName()); // verify the tag was deleted and removed from all associated channels Assertions.assertFalse(tagRepository.existsById(testTag1.getName()), "Failed to delete the tag"); - Assertions.assertEquals(new ArrayList(), channelRepository.search(params).getChannels(), "Failed to delete the tag from channels"); + Assertions.assertEquals(new ArrayList(), channelRepository.search(params).channels(), "Failed to delete the tag from channels"); } /** @@ -648,7 +648,7 @@ void deleteXmlTagFromChannel() { // Verify the tag is removed from the testChannel0 MultiValueMap searchParameters = new LinkedMultiValueMap(); searchParameters.add("~tag", testTag1.getName()); - Assertions.assertFalse(channelRepository.search(searchParameters).getChannels().stream().anyMatch(ch -> { + Assertions.assertFalse(channelRepository.search(searchParameters).channels().stream().anyMatch(ch -> { return ch.getName().equals(testChannels().get(0).getName()); }), "Failed to delete the tag from channel"); } diff --git a/src/test/java/org/phoebus/channelfinder/TagRepositoryIT.java b/src/test/java/org/phoebus/channelfinder/TagRepositoryIT.java index 5464f1cb..427b2299 100644 --- a/src/test/java/org/phoebus/channelfinder/TagRepositoryIT.java +++ b/src/test/java/org/phoebus/channelfinder/TagRepositoryIT.java @@ -228,7 +228,7 @@ void deleteXmlTag() { // verify the tag was deleted from all channels as expected MultiValueMap params = new LinkedMultiValueMap(); params.add("~tag","testChannel"); - List chans = channelRepository.search(params).getChannels(); + List chans = channelRepository.search(params).channels(); Assertions.assertTrue(chans.isEmpty(), "Failed to remove tag from channel"); // channel clean up