Copilot commented on code in PR #6127: URL: https://github.com/apache/texera/pull/6127#discussion_r3524137330
########## common/workflow-core/src/test/scala/org/apache/texera/amber/core/storage/util/dataset/PhysicalFileNodeSpec.scala: ########## @@ -0,0 +1,106 @@ +/* + * 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.texera.amber.core.storage.util.dataset + +import org.scalatest.flatspec.AnyFlatSpec + +import java.nio.file.{Files, Path} +import scala.jdk.CollectionConverters._ + +class PhysicalFileNodeSpec extends AnyFlatSpec { + + private def withRepo(body: Path => Unit): Unit = { + val repo = Files.createTempDirectory("pfn-") + try body(repo) + finally { + Files + .walk(repo) + .sorted(java.util.Comparator.reverseOrder[Path]()) + .forEach(p => Files.deleteIfExists(p)) Review Comment: `Files.walk(repo)` returns a `java.util.stream.Stream` that should be closed. As written, the stream is never closed, which can leak file descriptors and can cause temp-directory cleanup to intermittently fail on some platforms (notably Windows) because the directory stream remains open. -- 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]
