From 713f0434372e85f5273ab7b544ca616a0f379f44 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Fri, 9 Jun 2023 11:30:21 +0200 Subject: SONAR-19532 PythonXUnitSensor takes too long due to non-optimized file query --- .../internal/predicates/DefaultFilePredicates.java | 5 ++- .../batch/fs/internal/predicates/IsPredicate.java | 43 ---------------------- 2 files changed, 4 insertions(+), 44 deletions(-) delete mode 100644 sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/IsPredicate.java (limited to 'sonar-plugin-api-impl/src/main') diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/DefaultFilePredicates.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/DefaultFilePredicates.java index 37345e7d455..bc0a5dc87fb 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/DefaultFilePredicates.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/DefaultFilePredicates.java @@ -133,7 +133,10 @@ public class DefaultFilePredicates implements FilePredicates { @Override public FilePredicate is(File ioFile) { - return new IsPredicate(ioFile.toPath()); + if (ioFile.isAbsolute()) { + return hasAbsolutePath(ioFile.getAbsolutePath()); + } + return hasRelativePath(ioFile.getPath()); } @Override diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/IsPredicate.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/IsPredicate.java deleted file mode 100644 index 80b861e40f1..00000000000 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/predicates/IsPredicate.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.batch.fs.internal.predicates; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import org.sonar.api.batch.fs.InputFile; - -public class IsPredicate extends AbstractFilePredicate { - - private final Path path; - - public IsPredicate(Path path) { - this.path = path; - } - - @Override - public boolean apply(InputFile inputFile) { - try { - return Files.isSameFile(path, inputFile.path()); - } catch (IOException e) { - return false; - } - } -} -- cgit v1.2.3