Kaynağa Gözat

Fixing Warnings and Build Errors

Warning 1:
WARNING: A Java agent has been loaded dynamically
(\.m2\repository\net\bytebuddy\byte-buddy-agent\1.14.9\byte-buddy-agent-1.14.9.jar)
WARNING: If a serviceability tool is in use, please run with
-XX:+EnableDynamicAgentLoading to hide this warning
WARNING: If a serviceability tool is not in use, please run with
-Djdk.instrument.traceUsage for more information
WARNING: Dynamic loading of agents will be disallowed by default in a
future release

Warning 2:
Annotation processing is enabled because one or more processors were
found on the class path. A future release of javac may disable
annotation processing unless at least one processor is specified by name
(-processor), or a search path is specified (--processor-path,
--processor-module-path), or annotation processing is enabled explicitly
(-proc:only, -proc:full).
Use -Xlint:-options to suppress this message.
Use -proc:none to disable annotation processing.

Warning 3:
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot
loader classes because bootstrap classpath has been appended
Zoey76 1 yıl önce
ebeveyn
işleme
93c00daf0f

+ 11 - 11
bitbucket-pipelines.yml

@@ -2,20 +2,20 @@ image: eclipse-temurin:21.0.1_12-jdk-ubi9-minimal
 
 pipelines:
    default:
-      - step:
+   -  step:
          caches:
-          - maven
+         - maven
          script:
-          - /bin/sh mvnw install
+         - /bin/sh mvnw install
          artifacts:
-          - target/*.zip
-      - step:
+         - target/*.zip
+   -  step:
          deployment: Production
          script:
-          - pipe: atlassian/ftp-deploy:0.6.0
+         -  pipe: atlassian/ftp-deploy:0.6.0
             variables:
-              USER: $FTP_USER
-              PASSWORD: $FTP_PASSWORD
-              SERVER: $FTP_HOST
-              REMOTE_PATH: $FTP_REMOTE_PATH
-              LOCAL_PATH: 'target/'
+               USER: $FTP_USER
+               PASSWORD: $FTP_PASSWORD
+               SERVER: $FTP_HOST
+               REMOTE_PATH: $FTP_REMOTE_PATH
+               LOCAL_PATH: target/

+ 14 - 2
pom.xml

@@ -27,9 +27,10 @@
 		<assertj-core.version>3.24.2</assertj-core.version>
 		<!-- Plugins -->
 		<dependency-check-maven.version>9.0.2</dependency-check-maven.version>
-		<maven-surefire-plugin.version>3.2.2</maven-surefire-plugin.version>
-		<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
 		<maven-assembly-plugin.version>3.6.0</maven-assembly-plugin.version>
+		<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
+		<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
+		<maven-surefire-plugin.version>3.2.2</maven-surefire-plugin.version>
 	</properties>
 	<repositories>
 		<repository>
@@ -44,6 +45,17 @@
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-surefire-plugin</artifactId>
 				<version>${maven-surefire-plugin.version}</version>
+				<configuration>
+					<argLine>-XX:+EnableDynamicAgentLoading -Xshare:off</argLine>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>${maven-compiler-plugin.version}</version>
+				<configuration>
+					<proc>full</proc>
+				</configuration>
 			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>

+ 1 - 1
src/main/java/com/l2jserver/gameserver/cache/HtmCache.java

@@ -64,7 +64,7 @@ public class HtmCache {
 		if (!general().lazyCache()) {
 			LOG.info("Html cache start...");
 			parseDir(f);
-			LOG.info(String.format("%.3f", getMemoryUsage()) + " megabytes on " + getLoadedFiles() + " files loaded");
+			LOG.info(String.format("%.3f", getMemoryUsage()) + " megabytes on " + getLoadedFiles() + " files loaded.");
 		} else {
 			HTML_CACHE.clear();
 			_loadedFiles = 0;

+ 3 - 5
src/main/java/com/l2jserver/gameserver/data/xml/impl/NpcData.java

@@ -31,7 +31,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.function.Predicate;
-import java.util.stream.Collectors;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -542,11 +541,10 @@ public class NpcData implements IXmlReader {
 	 * @return the template list for the given filter
 	 */
 	public List<L2NpcTemplate> getTemplates(Predicate<L2NpcTemplate> filter) {
-		//@formatter:off
-			return _npcs.values().stream()
+		return _npcs.values()
+			.stream()
 			.filter(filter)
-			.collect(Collectors.toList());
-		//@formatter:on
+			.toList();
 	}
 	
 	/**

+ 8 - 37
src/main/java/com/l2jserver/gameserver/util/IXmlReader.java

@@ -23,7 +23,6 @@ import static com.l2jserver.gameserver.config.Configuration.server;
 import java.io.File;
 import java.io.FileFilter;
 
-import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.slf4j.Logger;
@@ -77,13 +76,13 @@ public interface IXmlReader {
 			return;
 		}
 		
-		final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+		final var dbf = DocumentBuilderFactory.newInstance();
 		dbf.setNamespaceAware(true);
 		dbf.setValidating(true);
 		dbf.setIgnoringComments(true);
 		try {
 			dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
-			final DocumentBuilder db = dbf.newDocumentBuilder();
+			final var db = dbf.newDocumentBuilder();
 			db.setErrorHandler(new XMLErrorHandler());
 			parseDocument(db.parse(f), f);
 		} catch (SAXParseException e) {
@@ -93,34 +92,6 @@ public interface IXmlReader {
 		}
 	}
 	
-	/**
-	 * Wrapper for {@link #parseDirectory(File, boolean)}.
-	 * @param file the path to the directory where the XML files are.
-	 * @return {@code false} if it fails to find the directory, {@code true} otherwise.
-	 */
-	default boolean parseDirectory(File file) {
-		return parseDirectory(file, false);
-	}
-	
-	/**
-	 * Wrapper for {@link #parseDirectory(File, boolean)}.
-	 * @param path the path to the directory where the XML files are.
-	 * @return {@code false} if it fails to find the directory, {@code true} otherwise.
-	 */
-	default boolean parseDirectory(String path) {
-		return parseDirectory(new File(path), false);
-	}
-	
-	/**
-	 * Wrapper for {@link #parseDirectory(File, boolean)}.
-	 * @param path the path to the directory where the XML files are.
-	 * @param recursive parses all sub folders if there is.
-	 * @return {@code false} if it fails to find the directory, {@code true} otherwise.
-	 */
-	default boolean parseDirectory(String path, boolean recursive) {
-		return parseDirectory(new File(path), recursive);
-	}
-	
 	/**
 	 * Loads all XML files from {@code path} and calls {@link #parseFile(File)} for each one of them.
 	 * @param dir the directory object to scan.
@@ -133,13 +104,13 @@ public interface IXmlReader {
 			return false;
 		}
 		
-		final File[] files = dir.listFiles();
+		final var files = dir.listFiles();
 		if (files != null) {
-			for (File f : files) {
-				if (recursive && f.isDirectory()) {
-					parseDirectory(f, recursive);
-				} else if (getCurrentFileFilter().accept(f)) {
-					parseFile(f);
+			for (var file : files) {
+				if (recursive && file.isDirectory()) {
+					parseDirectory(file, recursive);
+				} else if (getCurrentFileFilter().accept(file)) {
+					parseFile(file);
 				}
 			}
 		}

+ 1 - 0
src/main/java/com/l2jserver/gameserver/util/file/filter/ExtFilter.java

@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.FileFilter;
 
 /**
+ * Extension Filter.
  * @author lasarus
  */
 public class ExtFilter implements FileFilter {