gnodet commented on code in PR #11389:
URL: https://github.com/apache/maven/pull/11389#discussion_r2495234965


##########
impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultTempFileService.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.internal.impl;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import java.io.IOException;
+import java.nio.file.FileVisitOption;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Supplier;
+
+import org.apache.maven.api.Session;
+import org.apache.maven.api.SessionData;
+import org.apache.maven.api.services.TempFileService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Default TempFileService implementation.
+ * Stores tracked paths in Session-scoped data and removes them after the 
build.
+ */
+@Named
+@Singleton
+public final class DefaultTempFileService implements TempFileService {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(DefaultTempFileService.class);
+
+    // System property to keep temp material for diagnostics.
+    private static final String KEEP_PROP = "maven.tempfile.keep";
+
+    // unique, typed session key (uses factory; one narrow unchecked cast)
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    private static final SessionData.Key<Set<Path>> TMP_KEY =
+            (SessionData.Key) SessionData.key(Set.class, 
DefaultTempFileService.class);
+
+    // supplier with concrete types (avoids inference noise)
+    private static final Supplier<Set<Path>> TMP_SUPPLIER =
+            () -> Collections.newSetFromMap(new ConcurrentHashMap<Path, 
Boolean>());
+
+    @Inject
+    public DefaultTempFileService() {
+        // default
+    }
+
+    @Override
+    public Path createTempFile(final Session session, final String prefix, 
final String suffix) throws IOException {

Review Comment:
   No need to use final on arguments or variables.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to