Skip to content

Commit

Permalink
Fix write-to-read-only array issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
groboclown committed Feb 27, 2020
1 parent feda4b8 commit 1c6c6e5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
12 changes: 12 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# IDEA Community VCS Integration for Perforce


## ::v0.10.13::

### Overview

* Bug fixes

### Details

* Bug fixes
* Fixed a problem where a write is performed to a read-only list (#210 and )


## ::v0.10.12::

### Overview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,8 @@ private ListOpenedFilesChangesResult listOpenedFilesChanges(IClient client, Clie
// This is a complex call, because we perform all the open requests in a single method.

// First, find all the pending changelists for the client.
List<IChangelistSummary> summaries = cmd.getPendingChangelists(client, maxChangelistResults);
List<IChangelistSummary> summaries = new ArrayList<>(cmd.getPendingChangelists(client,
maxChangelistResults));

// Then get details about the changelists.
List<IChangelist> changes = new ArrayList<>(summaries.size());
Expand Down Expand Up @@ -942,8 +943,9 @@ private ListOpenedFilesChangesResult listOpenedFilesChanges(IClient client, Clie
pendingChangelistFileSummaries.size() + " files, maximum file count " +
maxFileResults + ")");
}
List<IExtendedFileSpec> pendingChangelistFiles = cmd.getFileDetailsForOpenedSpecs(
client.getServer(), pendingChangelistFileSummaries, maxFileResults);
// #210 and #207 - don't write to a potentially read-only list.
List<IExtendedFileSpec> pendingChangelistFiles = new ArrayList<>(cmd.getFileDetailsForOpenedSpecs(
client.getServer(), pendingChangelistFileSummaries, maxFileResults));
Iterator<IExtendedFileSpec> pendingIter = pendingChangelistFiles.iterator();
// TODO DEBUG variable; remove when that code path stablizes.
boolean foundNonOpened = false;
Expand Down Expand Up @@ -982,12 +984,15 @@ private ListOpenedFilesChangesResult listOpenedFilesChanges(IClient client, Clie
}
}

// #210 and #207 - don't write to a potentially read-only list.

// Then get opened files in the default changelist.
LOG.debug("listOpenedFilesChanges@" + startDate + ": getting file details for default changelist");
List<IExtendedFileSpec> openedDefaultChangelistFiles =
cmd.getFilesOpenInDefaultChangelist(client.getServer(), client.getName(), maxFileResults);
new ArrayList<>(cmd.getFilesOpenInDefaultChangelist(client.getServer(), client.getName(),
maxFileResults));
List<IExtendedFileSpec> defaultAddedFiles =
splitAddedFilesFromChangelistFileList(openedDefaultChangelistFiles);
new ArrayList<>(splitAddedFilesFromChangelistFileList(openedDefaultChangelistFiles));
Iterator<IExtendedFileSpec> defaultIter = openedDefaultChangelistFiles.iterator();
while (defaultIter.hasNext()) {
IExtendedFileSpec next = defaultIter.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.perforce.p4java.client.IClient;
import com.perforce.p4java.core.file.IExtendedFileSpec;
import com.perforce.p4java.core.file.IFileSpec;
import net.groboclown.p4.server.api.P4CommandRunner;
import net.groboclown.p4.server.api.commands.file.MoveFileAction;
Expand Down Expand Up @@ -70,8 +69,7 @@ public MoveFileResult moveFile(IClient client, ClientConfig config, P4CommandRun
LOG.info("Running move command for `" + srcFile + "` to `" + tgtFile + "`");
// Note the two separate fstat calls. These are limited, and are okay, but it might
// be better to join them together into a single call.
List<IExtendedFileSpec> srcStatusResponse = cmd.getFileDetailsForOpenedSpecs(client.getServer(), srcFile, 1);
OpenFileStatus srcStatus = new OpenFileStatus(srcStatusResponse);
OpenFileStatus srcStatus = new OpenFileStatus(cmd.getFileDetailsForOpenedSpecs(client.getServer(), srcFile, 1));
OpenFileStatus tgtStatus =
new OpenFileStatus(cmd.getFileDetailsForOpenedSpecs(client.getServer(), tgtFile, 1));
if (srcStatus.hasAdd()) {
Expand Down
8 changes: 4 additions & 4 deletions plugin-v3/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<idea-plugin>
<name>Perforce IDEA Community Integration</name>
<id>PerforceIC</id>
<version>0.10.12</version>
<version>0.10.13</version>
<!-- see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html -->
<idea-version since-build="171"/>
<category>VCS Integration</category>
<change-notes><![CDATA[
<ul>
<li><em>0.10.13</em><ul>
<li>Quick patch to incorrect "add" to a read-only list.</li>
</ul></li>
<li><em>0.10.12</em><ul>
<li>Altered the server connection to attempt to use the client configuration, even for calls that don't strictly need it.</li>
<li>Fixed an issue where diff display could show a diff against a changelist instead of a revision number.</li>
<li>Fixed an issue where the root paths would not be mapped to the client configuration correctly.</li>
<li>Cleaned up some of the logging.</li>
</ul></li>
<li><em>0.10.11</em><ul>
<li>Fixes to associating configuration with the VCS Root Directory.</li>
</ul></li>
</ul>
]]></change-notes>
<description><![CDATA[
Expand Down

0 comments on commit 1c6c6e5

Please sign in to comment.