Is the lock on Score always taken last? If not, synchonization on toString() 
could be risky with logging...

On Monday 17 November 2008 00:15, xor at freenetproject.org wrote:
> Author: xor
> Date: 2008-11-17 00:15:50 +0000 (Mon, 17 Nov 2008)
> New Revision: 23669
> 
> Modified:
>    trunk/plugins/WoT/Score.java
> Log:
> Synchronization.
> 
> Modified: trunk/plugins/WoT/Score.java
> ===================================================================
> --- trunk/plugins/WoT/Score.java      2008-11-17 00:12:46 UTC (rev 23668)
> +++ trunk/plugins/WoT/Score.java      2008-11-17 00:15:50 UTC (rev 23669)
> @@ -94,7 +94,7 @@
>               return query.execute();
>       }
>       
> -     public String toString() {
> +     public synchronized String toString() {
>               return getTarget().getNickName() + " has " + getScore() + " 
> points in " + 
getTreeOwner().getNickName() + "'s trust tree (rank : " + getRank() + ", 
capacity : " + getCapacity() + ")";
>       }
>  
> @@ -115,42 +115,42 @@
>       /**
>        * @return the numeric value of this Score
>        */
> -     public int getScore() {
> +     public synchronized int getScore() {
>               return score;
>       }
>  
>       /**
>        * Sets the numeric value of this Score
>        */
> -     public void setScore(int score) {
> +     public synchronized void setScore(int score) {
>               this.score = score;
>       }
>  
>       /**
>        * @return How far the target Identity is from the trust tree's root
>        */
> -     public int getRank() {
> +     public synchronized int getRank() {
>               return rank;
>       }
>  
>       /**
>        * Sets how far the target Identity is from the trust tree's root.
>        */
> -     public void setRank(int rank) {
> +     public synchronized void setRank(int rank) {
>               this.rank = rank;
>       }
>  
>       /**
>        * @return how much points the target Identity can add to its trustees 
score
>        */
> -     public int getCapacity() {
> +     public synchronized int getCapacity() {
>               return capacity;
>       }
>  
>       /**
>        * Sets how much points the target Identity can add to its trustees 
> score.
>        */
> -     public void setCapacity(int capacity) {
> +     public synchronized void setCapacity(int capacity) {
>               this.capacity = capacity;
>       }
>  }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20081204/d48b7795/attachment.pgp>

Reply via email to