# Bug in latest build: incomplete deal

**URL:** <https://forum.vassalengine.org/t/bug-in-latest-build-incomplete-deal/10760>\
**Category:** Technical Support & Bugs\
**Created:** [June 22, 2020, 9:02am UTC](https://forum.vassalengine.org/t/bug-in-latest-build-incomplete-deal/10760 "2020-06-22T09:02:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![slimy](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/slimy/32/4448_2.png) [@slimy](https://forum.vassalengine.org/u/slimy)\
**Post date:** [June 22, 2020, 9:02am UTC](https://forum.vassalengine.org/t/bug-in-latest-build-incomplete-deal/10760/1 "2020-06-22T09:02:08Z")

</div>

Module: [on google drive](https://drive.google.com/file/d/1neOXDY-tKyzBhVqXrDKrzf66Mbiyhjjx/view?usp=sharing)  
Java:   
openjdk 11.0.7 2020-04-14  
OpenJDK Runtime Environment (build 11.0.7+10-post-Debian-3deb10u1)  
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Debian-3deb10u1, mixed mode, sharing)  
OS: Linux leonhartsberger 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1+deb10u1 (2020-04-27) x86\_64 GNU/Linux

Everything is fine in 3.2.17 (where this was last saved). Everything is fine in 3.3.0. When I try to play a game in the build I did in this thread: [pdf doc](http://www.vassalengine.org/forum/viewtopic.php?f=3&t=11955&start=30) I hit an issue:

It should look like this: [6 role cards dealt.](https://drive.google.com/file/d/1sbr08VxerMYyzdR5I26kN-Xk7PnGQp_9/view?usp=sharing)  
In the faulty version it looks like: [only 4 cards dealt](https://drive.google.com/file/d/11bCIv3yvJNHJi4hMq_b_k0UE9GFLzFzY/view?usp=sharing). (It makes no difference whether I bother to set the names or not.)

Steps to reproduce:

1. Log on as the “Convener”.
2. Enter the window marked “Role” from the toolbar.
3. Click on the “bell” button in the top-left corner.

---

<div class="post-metadata">

**Author:** ![slimy](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/slimy/32/4448_2.png) [@slimy](https://forum.vassalengine.org/u/slimy)\
**Post date:** [June 22, 2020, 11:34am UTC](https://forum.vassalengine.org/t/bug-in-latest-build-incomplete-deal/10760/2 "2020-06-22T11:34:58Z")

</div>

Not surprisingly if I just take a clean “git clone”. and build it still happens. So it was not the xdg-open fix that caused the problem. I did not think it would be but I am trying to see if I can pinpoint which commit did it.

---

<div class="post-metadata">

**Author:** ![slimy](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/slimy/32/4448_2.png) [@slimy](https://forum.vassalengine.org/u/slimy)\
**Post date:** [June 22, 2020, 12:03pm UTC](https://forum.vassalengine.org/t/bug-in-latest-build-incomplete-deal/10760/3 "2020-06-22T12:03:28Z")

</div>

I did a git bisect and I got the following:

[code]nicholas@leonhartsberger:~/VASSAL/src/vassal$ git bisect good  
f6053d0c7f7ce28a4998282e5ac585f89c170cff is the first bad commit  
commit f6053d0c7f7ce28a4998282e5ac585f89c170cff  
Author: yanlyub [yanlyub@users.noreply.github.com](mailto:yanlyub@users.noreply.github.com)  
Date: Mon Jun 15 21:46:28 2020 +0200

```
rewrote Stack.asList, removed outdated unit test

```

:040000 040000 a3d9dbd43215ccc96543aa5869f9144adafd8558 d6b060daaf71e0107c0bbdb08b2af57a23735656 M src  
:040000 040000 e90421ace3bcb2d216cc46ff9f87c7a57949db8f 5576b564b9fa2d41f65e95d0a2ed454432e0b9e6 M test  
nicholas@leonhartsberger:~/VASSAL/src/vassal$  
[/code]

---

<div class="post-metadata">

**Author:** ![slimy](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/slimy/32/4448_2.png) [@slimy](https://forum.vassalengine.org/u/slimy)\
**Post date:** [June 22, 2020, 12:18pm UTC](https://forum.vassalengine.org/t/bug-in-latest-build-incomplete-deal/10760/4 "2020-06-22T12:18:22Z")

</div>

It looks like the offending code is here:

[code]— a/src/VASSAL/counters/Stack.java  
+++ b/src/VASSAL/counters/Stack.java  
@@ -90,11 +90,7 @@ public class Stack implements GamePiece, StateMergeable {  
\* @return an unmodifiable {@link List} of {@link GamePiece}s contained in th  
is {@link Stack}  
\*/  
public List asList() {

- List result = new ArrayList\<\>();
- for (int i = 0; i \< pieceCount; i++) {
- 

```
 result.add(contents[i]);

```

- }
- return Collections.unmodifiableList(result);

- return Collections.unmodifiableList(Arrays.asList(contents).subList(0, pieceCount));  
}

[/code]

---

<div class="post-metadata">

**Author:** ![slimy](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/slimy/32/4448_2.png) [@slimy](https://forum.vassalengine.org/u/slimy)\
**Post date:** [June 22, 2020, 12:24pm UTC](https://forum.vassalengine.org/t/bug-in-latest-build-incomplete-deal/10760/5 "2020-06-22T12:24:55Z")

</div>

I found this also affects Tigris and Euphrates. In determining player order only 3 out of 4 tokens are dealt.

---

<div class="post-metadata">

**Author:** ![Flint1b](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/flint1b/32/246_2.png) [@Flint1b](https://forum.vassalengine.org/u/Flint1b)\
**Post date:** [June 22, 2020, 2:02pm UTC](https://forum.vassalengine.org/t/bug-in-latest-build-incomplete-deal/10760/6 "2020-06-22T14:02:37Z")

</div>

Good job with the bisect.

Before that commit, a completely new list was created, and elements inserted into it.

After the commit, Arrays.asList() creates a list BACKED BY the array, and .subList() creates a sub list BACKED BY the list, so any change to the original array ends up in the supposedly unmodifiable list. This can lead to various problems down the line.

---

<div class="post-metadata">

**Author:** ![Flint1b](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/flint1b/32/246_2.png) [@Flint1b](https://forum.vassalengine.org/u/Flint1b)\
**Post date:** [June 22, 2020, 2:27pm UTC](https://forum.vassalengine.org/t/bug-in-latest-build-incomplete-deal/10760/7 "2020-06-22T14:27:52Z")

</div>

A unit test confirmed my assumption, the List that is returned from asList() changes if pieces are removed from the stack after getting the list.

[github.com/vassalengine/vassal/pull/29](https://github.com/vassalengine/vassal/pull/29) should fix this by reverting it to the previous version with the manually built new list.

Some day we will get rid of this array extremism inside the Stack, with the manual counting of array contents and manual resizing of the array. For this we need to un-inherit the Deck from the Stack, then replace the array with a regular list. And write lots of unit tests. I’m on it.

---

<div class="post-metadata">

**Author:** ![slimy](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/slimy/32/4448_2.png) [@slimy](https://forum.vassalengine.org/u/slimy)\
**Post date:** [June 22, 2020, 2:55pm UTC](https://forum.vassalengine.org/t/bug-in-latest-build-incomplete-deal/10760/8 "2020-06-22T14:55:33Z")

</div>

Okay I did a fresh clone and pulled both fixes. Everything seems okay at the moment. Thanks.

---

<div class="post-metadata">

**Author:** ![uckelman](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/uckelman/32/10020_2.png) [@uckelman](https://forum.vassalengine.org/u/uckelman)\
**Post date:** [June 22, 2020, 3:07pm UTC](https://forum.vassalengine.org/t/bug-in-latest-build-incomplete-deal/10760/9 "2020-06-22T15:07:27Z")

</div>

Thus spake slimy:

> Okay I did a fresh clone and pulled both fixes. Everything seems okay at  
> the moment. Thanks.

Fix is merged to master at dc947b5ab.

–  
J.
