[Libreoffice-commits] core.git: 3 commits - bean/com qadevOOo/tests scripting/java
Noel Grandin
noel at peralex.com
Wed Oct 14 03:31:22 PDT 2015
bean/com/sun/star/comp/beans/LocalOfficeConnection.java | 25 +++----
qadevOOo/tests/java/ifc/sheet/_XSpreadsheets.java | 6 +
scripting/java/com/sun/star/script/framework/container/ParcelContainer.java | 34 +++++-----
3 files changed, 35 insertions(+), 30 deletions(-)
New commits:
commit 977ac8ae64b9363ec56d7f2c56f40d2325f8b756
Author: Noel Grandin <noel at peralex.com>
Date: Wed Oct 14 12:29:33 2015 +0200
cid#1326363 Data race condition
Change-Id: I149d857ee9e51df72e91981185ff0970e7f63ca5
diff --git a/qadevOOo/tests/java/ifc/sheet/_XSpreadsheets.java b/qadevOOo/tests/java/ifc/sheet/_XSpreadsheets.java
index fe7188b..2944e9c 100644
--- a/qadevOOo/tests/java/ifc/sheet/_XSpreadsheets.java
+++ b/qadevOOo/tests/java/ifc/sheet/_XSpreadsheets.java
@@ -17,6 +17,8 @@
*/
package ifc.sheet;
+import java.util.concurrent.atomic.AtomicInteger;
+
import com.sun.star.sheet.XSpreadsheets;
import lib.MultiMethodTest;
@@ -34,7 +36,7 @@ import lib.MultiMethodTest;
* @see com.sun.star.sheet.XSpreadsheets
*/
public class _XSpreadsheets extends MultiMethodTest {
- protected static int uniqCount = 0;
+ private static final AtomicInteger uniqCount = new AtomicInteger(0);
public XSpreadsheets oObj = null;
protected int uniqNumber = 0;
@@ -43,7 +45,7 @@ public class _XSpreadsheets extends MultiMethodTest {
*/
@Override
protected synchronized void before() {
- uniqNumber = uniqCount++;
+ uniqNumber = uniqCount.getAndIncrement();
}
/**
commit 43cbaac5b96897295e3e97d2677e9087dc0fa11c
Author: Noel Grandin <noel at peralex.com>
Date: Wed Oct 14 12:23:04 2015 +0200
cid#1326361 Data race condition
Change-Id: Ia61737232d816bb05f3aedbe76e7905262906a79
diff --git a/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java b/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java
index 68db1cf..ddbd460 100644
--- a/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java
+++ b/scripting/java/com/sun/star/script/framework/container/ParcelContainer.java
@@ -58,14 +58,14 @@ import java.util.StringTokenizer;
*/
public class ParcelContainer implements XNameAccess {
+ protected static XSimpleFileAccess m_xSFA;
+
protected String language;
protected String containerUrl;
private Collection<Parcel> parcels = new ArrayList<Parcel>(10);
- protected static XSimpleFileAccess m_xSFA;
protected XComponentContext m_xCtx;
private ParcelContainer parent = null;
- private final Collection<ParcelContainer> childContainers = new
- ArrayList<ParcelContainer>(10);
+ private final Collection<ParcelContainer> childContainers = new ArrayList<ParcelContainer>(10);
private boolean isPkgContainer = false;
/**
@@ -276,22 +276,24 @@ public class ParcelContainer implements XNameAccess {
return this.containerUrl;
}
- private synchronized void initSimpleFileAccess() {
- if (m_xSFA != null) {
- return;
- }
+ private void initSimpleFileAccess() {
+ synchronized (ParcelContainer.class) {
+ if (m_xSFA != null) {
+ return;
+ }
- try {
+ try {
- m_xSFA = UnoRuntime.queryInterface(
- XSimpleFileAccess.class,
- m_xCtx.getServiceManager().createInstanceWithContext(
- "com.sun.star.ucb.SimpleFileAccess", m_xCtx));
+ m_xSFA = UnoRuntime.queryInterface(
+ XSimpleFileAccess.class,
+ m_xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.ucb.SimpleFileAccess", m_xCtx));
- } catch (Exception e) {
- // TODO should throw
- LogUtils.DEBUG("Error instantiating simplefile access ");
- LogUtils.DEBUG(LogUtils.getTrace(e));
+ } catch (Exception e) {
+ // TODO should throw
+ LogUtils.DEBUG("Error instantiating simplefile access ");
+ LogUtils.DEBUG(LogUtils.getTrace(e));
+ }
}
}
commit 62289290415ae46800d703352e87c5b8f7807552
Author: Noel Grandin <noel at peralex.com>
Date: Wed Oct 14 12:19:44 2015 +0200
cid#1326360 Data race condition
Change-Id: Ie7af8c5e5d96b74faab18fd82355a0ab0ecc4f65
diff --git a/bean/com/sun/star/comp/beans/LocalOfficeConnection.java b/bean/com/sun/star/comp/beans/LocalOfficeConnection.java
index 117ff39..43e91fb 100644
--- a/bean/com/sun/star/comp/beans/LocalOfficeConnection.java
+++ b/bean/com/sun/star/comp/beans/LocalOfficeConnection.java
@@ -21,23 +21,24 @@ package com.sun.star.comp.beans;
import java.awt.Container;
import java.io.File;
import java.io.UnsupportedEncodingException;
-import java.util.Iterator;
-import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
-import com.sun.star.lang.XMultiComponentFactory;
-import com.sun.star.lang.XComponent;
-import com.sun.star.lang.XEventListener;
-import com.sun.star.connection.XConnection;
-import com.sun.star.connection.XConnector;
+import com.sun.star.beans.XPropertySet;
import com.sun.star.bridge.XBridge;
import com.sun.star.bridge.XBridgeFactory;
-import com.sun.star.beans.XPropertySet;
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.uno.UnoRuntime;
+import com.sun.star.connection.XConnection;
+import com.sun.star.connection.XConnector;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XEventListener;
+import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lib.uno.helper.UnoUrl;
import com.sun.star.lib.util.NativeLibraryLoader;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
/**
* This class represents a connection to the local office application.
@@ -64,7 +65,7 @@ public class LocalOfficeConnection
private final List<XEventListener> mComponents = new ArrayList<XEventListener>();
- private static long m_nBridgeCounter = 0;
+ private static final AtomicLong m_nBridgeCounter = new AtomicLong(0);
static
{
@@ -443,7 +444,7 @@ public class LocalOfficeConnection
// empty string as bridge name into createBridge. Then we should always get
// a new bridge. This does not work because of (i51323). Therefore we
// create unique bridge names for the current process.
- String sBridgeName = "OOoBean_private_bridge_" + (m_nBridgeCounter++);
+ String sBridgeName = "OOoBean_private_bridge_" + m_nBridgeCounter.getAndIncrement();
try {
mBridge = xBridgeFactory.createBridge(sBridgeName, protDcp, xConnection, null);
} catch (com.sun.star.bridge.BridgeExistsException e) {
More information about the Libreoffice-commits
mailing list