diff --git a/CHANGES.md b/CHANGES.md index 333f73c7..e7004b9d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ * Fixed part of a bug where the VCS root configuration shared options between root directories (#211). This is only a partial fix, as there's an underlying bug in the IDE that causes this problem. The resolved properties panel shows the path that's being set, so if the UI seems to show the wrong path, it's because of this underlying bug. * Fixed some NPEs caused by certain error and logging conditions. * Normalized the path view in the connections panel for Windows. + * Fixed a problem when file locations don't map to a client workspace file ("null file spec in arguments"). ## ::v0.10.13:: and ::v0.10.14:: diff --git a/idea-p4server/api/src/main/java/net/groboclown/p4/server/api/util/CollectionUtil.java b/idea-p4server/api/src/main/java/net/groboclown/p4/server/api/util/CollectionUtil.java new file mode 100644 index 00000000..9accc8b0 --- /dev/null +++ b/idea-p4server/api/src/main/java/net/groboclown/p4/server/api/util/CollectionUtil.java @@ -0,0 +1,43 @@ +/* + * Licensed 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 net.groboclown.p4.server.api.util; + +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +/** + * General utilities for working with collections. + */ +public class CollectionUtil { + /** + * Filter out null entries from the list. Returns a modifiable list. + * + * @param values values to filter + * @param type in the array. It's nullable on the arguments, but not null in the return. + * @return + */ + @NotNull + public static ArrayList filterNulls(@NotNull List values) { + ArrayList ret = new ArrayList<>(values.size()); + for (T v: values) { + if (v != null) { + ret.add(v); + } + } + return ret; + } +} diff --git a/idea-p4server/impl/src/main/java/net/groboclown/p4/server/impl/connection/ConnectCommandRunner.java b/idea-p4server/impl/src/main/java/net/groboclown/p4/server/impl/connection/ConnectCommandRunner.java index 2bdd4f4c..704ff9e4 100644 --- a/idea-p4server/impl/src/main/java/net/groboclown/p4/server/impl/connection/ConnectCommandRunner.java +++ b/idea-p4server/impl/src/main/java/net/groboclown/p4/server/impl/connection/ConnectCommandRunner.java @@ -103,6 +103,7 @@ import net.groboclown.p4.server.api.config.ClientConfig; import net.groboclown.p4.server.api.config.OptionalClientServerConfig; import net.groboclown.p4.server.api.messagebus.SpecialFileEventMessage; +import net.groboclown.p4.server.api.util.CollectionUtil; import net.groboclown.p4.server.api.values.P4ChangelistId; import net.groboclown.p4.server.api.values.P4FileRevision; import net.groboclown.p4.server.api.values.P4FileType; @@ -410,7 +411,9 @@ public P4CommandRunner.QueryAnswer getFileContents( if (rev <= 0 && localFile.getIOFile().exists()) { return FileUtil.loadFileBytes(localFile.getIOFile()); } else { - List locations = cmd.getSpecLocations(client, FileSpecBuildUtil.escapedForFilePathRev(localFile, -1)); + // Note: filter out the specs that don't map to anything in the client. + List locations = CollectionUtil.filterNulls(cmd.getSpecLocations(client, + FileSpecBuildUtil.escapedForFilePathRev(localFile, -1))); if (locations.isEmpty()) { locations = FileSpecBuildUtil.escapedForFilePathRev(localFile, rev); } else { diff --git a/idea-p4server/impl/src/main/java/net/groboclown/p4/server/impl/connection/impl/P4CommandUtil.java b/idea-p4server/impl/src/main/java/net/groboclown/p4/server/impl/connection/impl/P4CommandUtil.java index 5719fad2..66c4eb99 100644 --- a/idea-p4server/impl/src/main/java/net/groboclown/p4/server/impl/connection/impl/P4CommandUtil.java +++ b/idea-p4server/impl/src/main/java/net/groboclown/p4/server/impl/connection/impl/P4CommandUtil.java @@ -558,6 +558,16 @@ public List moveFile(IClient client, IFileSpec source, IFileSpec targ return client.getServer().moveFile(source, target, options); } + /** + * Returns 1 spec location for each spec input, with a possible null returned entry if there + * is no corresponding location on the server. + * + * @param client + * @param specs + * @return + * @throws ConnectionException + * @throws AccessException + */ public List getSpecLocations(IClient client, List specs) throws ConnectionException, AccessException { return client.where(specs); diff --git a/plugin-v3/src/main/resources/META-INF/plugin.xml b/plugin-v3/src/main/resources/META-INF/plugin.xml index 467abefc..e5c3da5b 100644 --- a/plugin-v3/src/main/resources/META-INF/plugin.xml +++ b/plugin-v3/src/main/resources/META-INF/plugin.xml @@ -11,6 +11,7 @@
  • The VCS root directory options now better sets values independently between roots.
  • Fixed some NPEs caused by certain error and logging conditions.
  • Normalized the path view in the connections panel for Windows.
  • +
  • Fixed a problem when file locations don't map to a client workspace file.
  • 0.10.13 and 0.10.14
    • Quick patch to incorrect "add" to a read-only list.