Skip to content

Commit

Permalink
Fixed a problem when file locations don't map to a client workspace f…
Browse files Browse the repository at this point in the history
…ile ("null file spec in arguments").
  • Loading branch information
groboclown committed Mar 2, 2020
1 parent 835b505 commit e66b168
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <T> type in the array. It's nullable on the arguments, but not null in the return.
* @return
*/
@NotNull
public static <T> ArrayList<T> filterNulls(@NotNull List<T> values) {
ArrayList<T> ret = new ArrayList<>(values.size());
for (T v: values) {
if (v != null) {
ret.add(v);
}
}
return ret;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -410,7 +411,9 @@ public P4CommandRunner.QueryAnswer<GetFileContentsResult> getFileContents(
if (rev <= 0 && localFile.getIOFile().exists()) {
return FileUtil.loadFileBytes(localFile.getIOFile());
} else {
List<IFileSpec> locations = cmd.getSpecLocations(client, FileSpecBuildUtil.escapedForFilePathRev(localFile, -1));
// Note: filter out the specs that don't map to anything in the client.
List<IFileSpec> locations = CollectionUtil.filterNulls(cmd.getSpecLocations(client,
FileSpecBuildUtil.escapedForFilePathRev(localFile, -1)));
if (locations.isEmpty()) {
locations = FileSpecBuildUtil.escapedForFilePathRev(localFile, rev);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,16 @@ public List<IFileSpec> 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<IFileSpec> getSpecLocations(IClient client, List<IFileSpec> specs)
throws ConnectionException, AccessException {
return client.where(specs);
Expand Down
1 change: 1 addition & 0 deletions plugin-v3/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<li>The VCS root directory options now better sets values independently between roots.</li>
<li>Fixed some NPEs caused by certain error and logging conditions.</li>
<li>Normalized the path view in the connections panel for Windows.</li>
<li>Fixed a problem when file locations don't map to a client workspace file.</li>
</ul></li>
<li><em>0.10.13 and 0.10.14</em><ul>
<li>Quick patch to incorrect "add" to a read-only list.</li>
Expand Down

0 comments on commit e66b168

Please sign in to comment.