ignite-4496 Review all logging for sensitive data leak
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b7d8d1b3 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b7d8d1b3 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b7d8d1b3 Branch: refs/heads/ignite-5075 Commit: b7d8d1b3f1376c6f83a60f73a90d47817cb159cc Parents: bfb2781 Author: Alexandr Kuramshin <[email protected]> Authored: Fri Jun 2 16:24:24 2017 +0300 Committer: sboikov <[email protected]> Committed: Fri Jun 2 16:24:24 2017 +0300 ---------------------------------------------------------------------- .../cache/store/jdbc/CacheJdbcBlobStore.java | 5 +- .../ignite/internal/binary/BinaryTypeProxy.java | 3 + .../stream/v2/DirectByteBufferStreamImplV2.java | 1 + .../checkpoint/GridCheckpointManager.java | 45 +- .../checkpoint/GridCheckpointRequest.java | 2 + .../processors/cache/GridCacheAdapter.java | 51 +- .../cache/GridCacheDeploymentManager.java | 12 +- .../distributed/dht/GridDhtCacheAdapter.java | 6 +- .../distributed/dht/GridDhtTxPrepareFuture.java | 9 +- ...arOptimisticSerializableTxPrepareFuture.java | 6 +- .../query/GridCacheQueryFutureAdapter.java | 18 +- .../store/GridCacheStoreManagerAdapter.java | 4 +- .../cache/store/GridCacheWriteBehindStore.java | 13 +- .../cache/transactions/TxDeadlock.java | 11 +- .../resource/GridResourceProcessor.java | 9 +- .../processors/task/GridTaskWorker.java | 4 +- .../util/tostring/GridToStringBuilder.java | 419 ++++++++++++++++ .../util/tostring/GridToStringThreadLocal.java | 6 +- .../internal/SensitiveInfoTestLoggerProxy.java | 493 +++++++++++++++++++ .../SensitiveInfoTestLoggerProxy_Exclude.txt | 20 + .../SensitiveInfoTestLoggerProxy_Include.txt | 18 + .../tostring/IncludeSensitiveAtomicTest.java | 29 ++ .../util/tostring/IncludeSensitiveTest.java | 149 ++++++ .../IncludeSensitiveTransactionalTest.java | 43 ++ .../junits/IgniteTestResources.java | 11 +- 25 files changed, 1321 insertions(+), 66 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java index 2739865..88849f7 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java @@ -252,7 +252,10 @@ public class CacheJdbcBlobStore<K, V> extends CacheStoreAdapter<K, V> { V val = entry.getValue(); if (log.isDebugEnabled()) - log.debug("Store put [key=" + key + ", val=" + val + ", tx=" + tx + ']'); + log.debug(S.toString("Store put", + "key", key, true, + "val", val, true, + "tx", tx, false)); Connection conn = null; http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeProxy.java index 3a51050..57201e6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryTypeProxy.java @@ -22,6 +22,7 @@ import org.apache.ignite.binary.BinaryObject; import org.apache.ignite.binary.BinaryObjectException; import org.apache.ignite.binary.BinaryType; import org.apache.ignite.internal.util.tostring.GridToStringExclude; +import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import java.util.Collection; @@ -36,9 +37,11 @@ public class BinaryTypeProxy implements BinaryType { private final BinaryContext ctx; /** Type ID. */ + @GridToStringInclude(sensitive = true) private int typeId; /** Raw data. */ + @GridToStringInclude(sensitive = true) private final String clsName; /** Target type. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java index c92c470..9901b73 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java @@ -214,6 +214,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream { private final MessageFactory msgFactory; /** */ + @GridToStringExclude private ByteBuffer buf; /** */ http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java index aee958a..782ee5e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointManager.java @@ -185,16 +185,20 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> { case SESSION_SCOPE: { if (closedSess.contains(ses.getId())) { - U.warn(log, "Checkpoint will not be saved due to session invalidation [key=" + key + - ", val=" + state + ", ses=" + ses + ']', + U.warn(log, S.toString("Checkpoint will not be saved due to session invalidation", + "key", key, true, + "val", state, true, + "ses", ses, false), "Checkpoint will not be saved due to session invalidation."); break; } if (now > ses.getEndTime()) { - U.warn(log, "Checkpoint will not be saved due to session timeout [key=" + key + - ", val=" + state + ", ses=" + ses + ']', + U.warn(log, S.toString("Checkpoint will not be saved due to session timeout", + "key", key, true, + "val", state, true, + "ses", ses, false), "Checkpoint will not be saved due to session timeout."); break; @@ -217,8 +221,10 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> { // Double check. if (closedSess.contains(ses.getId())) { - U.warn(log, "Checkpoint will not be saved due to session invalidation [key=" + key + - ", val=" + state + ", ses=" + ses + ']', + U.warn(log, S.toString("Checkpoint will not be saved due to session invalidation", + "key", key, true, + "val", state, true, + "ses", ses, false), "Checkpoint will not be saved due to session invalidation."); keyMap.remove(ses.getId(), keys); @@ -228,8 +234,10 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> { } if (log.isDebugEnabled()) - log.debug("Resolved keys for session [keys=" + keys + ", ses=" + ses + - ", keyMap=" + keyMap + ']'); + log.debug(S.toString("Resolved keys for session", + "keys", keys, true, + "ses", ses, false, + "keyMap", keyMap, false)); // Note: Check that keys exists because session may be invalidated during saving // checkpoint from GridFuture. @@ -263,8 +271,11 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> { } } catch (IgniteSpiException e) { - throw new IgniteCheckedException("Failed to save checkpoint [key=" + key + ", val=" + state + ", scope=" + - scope + ", timeout=" + timeout + ']', e); + throw new IgniteCheckedException(S.toString("Failed to save checkpoint", + "key", key, true, + "val", state, true, + "scope", scope, false, + "timeout", timeout, false), e); } return saved; @@ -313,7 +324,8 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> { rmv = getSpi(ses.getCheckpointSpi()).removeCheckpoint(key); } else if (log.isDebugEnabled()) - log.debug("Checkpoint will not be removed (key map not found) [key=" + key + ", ses=" + ses + ']'); + log.debug(S.toString("Checkpoint will not be removed (key map not found)", + "key", key, true, "ses", ses, false)); return rmv; } @@ -345,7 +357,8 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> { return state; } catch (IgniteSpiException e) { - throw new IgniteCheckedException("Failed to load checkpoint: " + key, e); + throw new IgniteCheckedException(S.INCLUDE_SENSITIVE ? + ("Failed to load checkpoint: " + key) : "Failed to load checkpoint", e); } } @@ -389,14 +402,16 @@ public class GridCheckpointManager extends GridManagerAdapter<CheckpointSpi> { String msg; if (type == EVT_CHECKPOINT_SAVED) - msg = "Checkpoint saved: " + key; + msg = "Checkpoint saved"; else if (type == EVT_CHECKPOINT_LOADED) - msg = "Checkpoint loaded: " + key; + msg = "Checkpoint loaded"; else { assert type == EVT_CHECKPOINT_REMOVED : "Invalid event type: " + type; - msg = "Checkpoint removed: " + key; + msg = "Checkpoint removed"; } + if (S.INCLUDE_SENSITIVE) + msg += ": " + key; ctx.event().record(new CheckpointEvent(ctx.discovery().localNode(), msg, type, key)); } http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java index ddb4f26..8b21ff2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java @@ -19,6 +19,7 @@ package org.apache.ignite.internal.managers.checkpoint; import java.io.Externalizable; import java.nio.ByteBuffer; +import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.plugin.extensions.communication.Message; @@ -36,6 +37,7 @@ public class GridCheckpointRequest implements Message { private IgniteUuid sesId; /** */ + @GridToStringInclude(sensitive = true) private String key; /** */ http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index ff25dd9..cd781aa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -2240,7 +2240,10 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "put [key=" + key + ", val=" + val + ", filter=" + filter + ']'; + return S.toString("put", + "key", key, true, + "val", val, true, + "filter", filter, false); } }); } @@ -2290,7 +2293,10 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "putAsync [key=" + key + ", val=" + val + ", filter=" + filter + ']'; + return S.toString("putAsync", + "key", key, true, + "val", val, true, + "filter", filter, false); } }); } @@ -2345,7 +2351,10 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "putx [key=" + key + ", val=" + val + ", filter=" + filter + ']'; + return S.toString("putx", + "key", key, true, + "val", val, true, + "filter", filter, false); } }); @@ -2503,7 +2512,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "invokeAsync [key=" + key + ", entryProcessor=" + entryProcessor + ']'; + return S.toString("invokeAsync", + "key", key, true, + "entryProcessor", entryProcessor, false); } }); @@ -2550,7 +2561,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "invokeAllAsync [keys=" + keys + ", entryProcessor=" + entryProcessor + ']'; + return S.toString("invokeAllAsync", + "keys", keys, true, + "entryProcessor", entryProcessor, false); } }); @@ -2588,7 +2601,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "invokeAllAsync [map=" + map + ']'; + return S.toString("invokeAllAsync", + "map", map, true); } }); @@ -2768,7 +2782,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "putAll [map=" + m + ']'; + return S.toString("putAll", + "map", m, true); } }); } @@ -2798,7 +2813,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "putAllAsync [map=" + m + ']'; + return S.toString("putAllAsync", + "map", m, true); } }); } @@ -2851,7 +2867,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "remove [key=" + key + ']'; + return S.toString("remove", + "key", key, true); } }); } @@ -2892,7 +2909,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "removeAsync [key=" + key + ']'; + return S.toString("removeAsync", + "key", key, true); } }); } @@ -2954,7 +2972,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "removeAll [keys=" + keys + ']'; + return S.toString("removeAll", + "keys", keys, true); } }); } @@ -2995,7 +3014,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "removeAllAsync [keys=" + keys + ']'; + return S.toString("removeAllAsync", + "keys", keys, true); } }); } @@ -3047,7 +3067,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "removex [key=" + key + ']'; + return S.toString("removex", + "key", key, true); } }); @@ -3104,7 +3125,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } @Override public String toString() { - return "removeAsync [key=" + key + ", filter=" + filter + ']'; + return S.toString("removeAsync", + "key", key, true, + "filter", filter, false); } }); } http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java index 55e8669..a1eb706 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java @@ -351,10 +351,14 @@ public class GridCacheDeploymentManager<K, V> extends GridCacheSharedManagerAdap boolean res = F.eq(ldr, keyLdr) || F.eq(ldr, valLdr); if (log.isDebugEnabled()) - log.debug("Finished examining entry [entryCls=" + e.getClass() + - ", key=" + key0 + ", keyCls=" + key0.getClass() + - ", valCls=" + (val0 != null ? val0.getClass() : "null") + - ", keyLdr=" + keyLdr + ", valLdr=" + valLdr + ", res=" + res + ']'); + log.debug(S.toString("Finished examining entry", + "entryCls", e.getClass(), true, + "key", key0, true, + "keyCls", key0.getClass(), true, + "valCls", (val0 != null ? val0.getClass() : "null"), true, + "keyLdr", keyLdr, false, + "valLdr", valLdr, false, + "res", res, false)); return res; } http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java index 10caf07..c3d5f88 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java @@ -561,8 +561,10 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap } catch (GridDhtInvalidPartitionException e) { if (log.isDebugEnabled()) - log.debug("Ignoring entry for partition that does not belong [key=" + key + ", val=" + val + - ", err=" + e + ']'); + log.debug(S.toString("Ignoring entry for partition that does not belong", + "key", key, true, + "val", val, true, + "err", e, false)); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java index e2b7803..8a674fb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java @@ -1141,7 +1141,8 @@ public final class GridDhtTxPrepareFuture extends GridCacheCompoundFuture<Ignite assert key != null : entry.key(); - msg.append("key=").append(key.toString()).append(", keyCls=").append(key.getClass().getName()); + if (S.INCLUDE_SENSITIVE) + msg.append("key=").append(key.toString()).append(", keyCls=").append(key.getClass().getName()); } catch (Exception e) { msg.append("key=<failed to get key: ").append(e.toString()).append(">"); @@ -1154,8 +1155,10 @@ public final class GridDhtTxPrepareFuture extends GridCacheCompoundFuture<Ignite Object val = cacheVal != null ? cctx.unwrapBinaryIfNeeded(cacheVal, entry.keepBinary(), false) : null; - if (val != null) - msg.append(", val=").append(val.toString()).append(", valCls=").append(val.getClass().getName()); + if (val != null) { + if (S.INCLUDE_SENSITIVE) + msg.append(", val=").append(val.toString()).append(", valCls=").append(val.getClass().getName()); + } else msg.append(", val=null"); } http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java index 6060729..72ddc67 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java @@ -114,8 +114,10 @@ public class GridNearOptimisticSerializableTxPrepareFuture extends GridNearOptim Object key = entry.key().value(ctx.cacheObjectContext(), false); IgniteTxOptimisticCheckedException err0 = - new IgniteTxOptimisticCheckedException("Failed to prepare transaction, " + - "read/write conflict [key=" + key + ", cache=" + ctx.name() + ']'); + new IgniteTxOptimisticCheckedException(S.toString( + "Failed to prepare transaction, read/write conflict", + "key", key, true, + "cache", ctx.name(), false)); ERR_UPD.compareAndSet(this, null, err0); } http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java index 7ad7c31..c418ca2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryFutureAdapter.java @@ -369,18 +369,24 @@ public abstract class GridCacheQueryFutureAdapter<K, V, R> extends GridFutureAda return; if (log.isDebugEnabled()) - log.debug("Received query result page [nodeId=" + nodeId + ", data=" + data + - ", err=" + err + ", finished=" + finished + "]"); + log.debug(S.toString("Received query result page", + "nodeId", nodeId, false, + "data", data, true, + "err", err, false, + "finished", finished, false)); try { if (err != null) synchronized (this) { enqueue(Collections.emptyList()); - onDone(nodeId != null ? - new IgniteCheckedException("Failed to execute query on node [query=" + qry + - ", nodeId=" + nodeId + "]", err) : - new IgniteCheckedException("Failed to execute query locally: " + qry, err)); + onDone(new IgniteCheckedException(nodeId != null ? + S.toString("Failed to execute query on node", + "query", qry, true, + "nodeId", nodeId, false) : + S.toString("Failed to execute query locally", + "query", qry, true), + err)); onPage(nodeId, true); http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java index cf11a28..62ead23 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java @@ -331,7 +331,9 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt } if (log.isDebugEnabled()) - log.debug("Loaded value from store [key=" + key + ", val=" + val + ']'); + log.debug(S.toString("Loaded value from store", + "key", key, true, + "val", val, true)); if (convert) { val = convert(val); http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStore.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStore.java index 64238ab..831b1b0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStore.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStore.java @@ -419,7 +419,8 @@ public class GridCacheWriteBehindStore<K, V> implements CacheStore<K, V>, Lifecy /** {@inheritDoc} */ @Override public Map<K, V> loadAll(Iterable<? extends K> keys) { if (log.isDebugEnabled()) - log.debug("Store load all [keys=" + keys + ']'); + log.debug(S.toString("Store load all", + "keys", keys, true)); Map<K, V> loaded = new HashMap<>(); @@ -468,7 +469,8 @@ public class GridCacheWriteBehindStore<K, V> implements CacheStore<K, V>, Lifecy /** {@inheritDoc} */ @Override public V load(K key) { if (log.isDebugEnabled()) - log.debug("Store load [key=" + key + ']'); + log.debug(S.toString("Store load", + "key", key, true)); StatefulValue<K, V> val; @@ -510,7 +512,9 @@ public class GridCacheWriteBehindStore<K, V> implements CacheStore<K, V>, Lifecy @Override public void write(Entry<? extends K, ? extends V> entry) { try { if (log.isDebugEnabled()) - log.debug("Store put [key=" + entry.getKey() + ", val=" + entry.getValue() + ']'); + log.debug(S.toString("Store put", + "key", entry.getKey(), true, + "val", entry.getValue(), true)); updateCache(entry.getKey(), entry, StoreOperation.PUT); } @@ -530,7 +534,8 @@ public class GridCacheWriteBehindStore<K, V> implements CacheStore<K, V>, Lifecy @Override public void delete(Object key) { try { if (log.isDebugEnabled()) - log.debug("Store remove [key=" + key + ']'); + log.debug(S.toString("Store remove", + "key", key, true)); updateCache((K)key, null, StoreOperation.RMV); } http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlock.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlock.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlock.java index a613184..54fc9b3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlock.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlock.java @@ -21,11 +21,11 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; -import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.util.typedef.T2; +import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; /** @@ -139,9 +139,12 @@ public class TxDeadlock { Object val = txKey.key().value(cctx.cacheObjectContext(), true); sb.append(e.getValue()) - .append(" [key=") - .append(val) - .append(", cache=") + .append(" ["); + if (S.INCLUDE_SENSITIVE) + sb.append("key=") + .append(val) + .append(", "); + sb.append("cache=") .append(cctx.name()) .append("]\n"); } http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java index 1303f72..345bf34 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java @@ -36,6 +36,7 @@ import org.apache.ignite.internal.GridTaskSessionImpl; import org.apache.ignite.internal.managers.deployment.GridDeployment; import org.apache.ignite.internal.processors.GridProcessorAdapter; import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lifecycle.LifecycleBean; import org.apache.ignite.services.Service; import org.apache.ignite.spi.IgniteSpi; @@ -153,7 +154,7 @@ public class GridResourceProcessor extends GridProcessorAdapter { assert target != null; if (log.isDebugEnabled()) - log.debug("Injecting resources: " + target); + log.debug(S.toString("Injecting resources", "target", target, true)); // Unwrap Proxy object. target = unwrapTarget(target); @@ -239,7 +240,7 @@ public class GridResourceProcessor extends GridProcessorAdapter { assert obj != null; if (log.isDebugEnabled()) - log.debug("Injecting resources: " + obj); + log.debug(S.toString("Injecting resources", "obj", obj, true)); // Unwrap Proxy object. obj = unwrapTarget(obj); @@ -388,7 +389,7 @@ public class GridResourceProcessor extends GridProcessorAdapter { public void inject(GridDeployment dep, Class<?> taskCls, ComputeJob job, ComputeTaskSession ses, GridJobContextImpl jobCtx) throws IgniteCheckedException { if (log.isDebugEnabled()) - log.debug("Injecting resources: " + job); + log.debug(S.toString("Injecting resources", "job", job, true)); // Unwrap Proxy object. Object obj = unwrapTarget(job); @@ -432,7 +433,7 @@ public class GridResourceProcessor extends GridProcessorAdapter { public void inject(GridDeployment dep, ComputeTask<?, ?> task, GridTaskSessionImpl ses, ComputeLoadBalancer balancer, ComputeTaskContinuousMapper mapper) throws IgniteCheckedException { if (log.isDebugEnabled()) - log.debug("Injecting resources: " + task); + log.debug(S.toString("Injecting resources", "task", task, true)); // Unwrap Proxy object. Object obj = unwrapTarget(task); http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java index 62224f0..5a1bfdb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java @@ -1123,7 +1123,9 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject { } if (log.isDebugEnabled()) - log.debug("Reduced job responses [reduceRes=" + reduceRes + ", ses=" + ses + ']'); + log.debug(S.toString("Reduced job responses", + "reduceRes", reduceRes, true, + "ses", ses, false)); recordTaskEvent(EVT_TASK_REDUCED, "Task reduced."); } http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java index cffac65..0c49b51 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java @@ -153,6 +153,89 @@ public class GridToStringBuilder { * @param val3 Additional parameter value. * @param name4 Additional parameter name. * @param val4 Additional parameter value. + * @param name5 Additional parameter name. + * @param val5 Additional parameter value. + * @return String presentation of the given object. + */ + public static <T> String toString(Class<T> cls, T obj, + String name0, Object val0, + String name1, Object val1, + String name2, Object val2, + String name3, Object val3, + String name4, Object val4, + String name5, Object val5) { + return toString(cls, + obj, + name0, val0, false, + name1, val1, false, + name2, val2, false, + name3, val3, false, + name4, val4, false, + name5, val5, false); + } + + /** + * Produces auto-generated output of string presentation for given object and its declaration class. + * + * @param <T> Type of the object. + * @param cls Declaration class of the object. Note that this should not be a runtime class. + * @param obj Object to get a string presentation for. + * @param name0 Additional parameter name. + * @param val0 Additional parameter value. + * @param name1 Additional parameter name. + * @param val1 Additional parameter value. + * @param name2 Additional parameter name. + * @param val2 Additional parameter value. + * @param name3 Additional parameter name. + * @param val3 Additional parameter value. + * @param name4 Additional parameter name. + * @param val4 Additional parameter value. + * @param name5 Additional parameter name. + * @param val5 Additional parameter value. + * @param name6 Additional parameter name. + * @param val6 Additional parameter value. + * @return String presentation of the given object. + */ + public static <T> String toString(Class<T> cls, T obj, + String name0, Object val0, + String name1, Object val1, + String name2, Object val2, + String name3, Object val3, + String name4, Object val4, + String name5, Object val5, + String name6, Object val6) { + return toString(cls, + obj, + name0, val0, false, + name1, val1, false, + name2, val2, false, + name3, val3, false, + name4, val4, false, + name5, val5, false, + name6, val6, false); + } + + /** + * Produces auto-generated output of string presentation for given object and its declaration class. + * + * @param <T> Type of the object. + * @param cls Declaration class of the object. Note that this should not be a runtime class. + * @param obj Object to get a string presentation for. + * @param name0 Additional parameter name. + * @param val0 Additional parameter value. + * @param sens0 Property sensitive flag. + * @param name1 Additional parameter name. + * @param val1 Additional parameter value. + * @param sens1 Property sensitive flag. + * @param name2 Additional parameter name. + * @param val2 Additional parameter value. + * @param sens2 Property sensitive flag. + * @param name3 Additional parameter name. + * @param val3 Additional parameter value. + * @param sens3 Property sensitive flag. + * @param name4 Additional parameter name. + * @param val4 Additional parameter value. + * @param sens4 Property sensitive flag. * @return String presentation of the given object. */ public static <T> String toString(Class<T> cls, T obj, @@ -214,6 +297,178 @@ public class GridToStringBuilder { * @param obj Object to get a string presentation for. * @param name0 Additional parameter name. * @param val0 Additional parameter value. + * @param sens0 Property sensitive flag. + * @param name1 Additional parameter name. + * @param val1 Additional parameter value. + * @param sens1 Property sensitive flag. + * @param name2 Additional parameter name. + * @param val2 Additional parameter value. + * @param sens2 Property sensitive flag. + * @param name3 Additional parameter name. + * @param val3 Additional parameter value. + * @param sens3 Property sensitive flag. + * @param name4 Additional parameter name. + * @param val4 Additional parameter value. + * @param sens4 Property sensitive flag. + * @param name5 Additional parameter name. + * @param val5 Additional parameter value. + * @param sens5 Property sensitive flag. + * @return String presentation of the given object. + */ + public static <T> String toString(Class<T> cls, T obj, + String name0, Object val0, boolean sens0, + String name1, Object val1, boolean sens1, + String name2, Object val2, boolean sens2, + String name3, Object val3, boolean sens3, + String name4, Object val4, boolean sens4, + String name5, Object val5, boolean sens5) { + assert cls != null; + assert obj != null; + assert name0 != null; + assert name1 != null; + assert name2 != null; + assert name3 != null; + assert name4 != null; + assert name5 != null; + + Queue<GridToStringThreadLocal> queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] addNames = tmp.getAdditionalNames(); + Object[] addVals = tmp.getAdditionalValues(); + boolean[] addSens = tmp.getAdditionalSensitives(); + + addNames[0] = name0; + addVals[0] = val0; + addSens[0] = sens0; + addNames[1] = name1; + addVals[1] = val1; + addSens[1] = sens1; + addNames[2] = name2; + addVals[2] = val2; + addSens[2] = sens2; + addNames[3] = name3; + addVals[3] = val3; + addSens[3] = sens3; + addNames[4] = name4; + addVals[4] = val4; + addSens[4] = sens4; + addNames[5] = name5; + addVals[5] = val5; + addSens[5] = sens5; + + try { + return toStringImpl(cls, tmp.getStringBuilder(), obj, addNames, addVals, addSens, 6); + } + finally { + queue.offer(tmp); + } + } + + /** + * Produces auto-generated output of string presentation for given object and its declaration class. + * + * @param <T> Type of the object. + * @param cls Declaration class of the object. Note that this should not be a runtime class. + * @param obj Object to get a string presentation for. + * @param name0 Additional parameter name. + * @param val0 Additional parameter value. + * @param sens0 Property sensitive flag. + * @param name1 Additional parameter name. + * @param val1 Additional parameter value. + * @param sens1 Property sensitive flag. + * @param name2 Additional parameter name. + * @param val2 Additional parameter value. + * @param sens2 Property sensitive flag. + * @param name3 Additional parameter name. + * @param val3 Additional parameter value. + * @param sens3 Property sensitive flag. + * @param name4 Additional parameter name. + * @param val4 Additional parameter value. + * @param sens4 Property sensitive flag. + * @param name5 Additional parameter name. + * @param val5 Additional parameter value. + * @param sens5 Property sensitive flag. + * @param name6 Additional parameter name. + * @param val6 Additional parameter value. + * @param sens6 Property sensitive flag. + * @return String presentation of the given object. + */ + public static <T> String toString(Class<T> cls, T obj, + String name0, Object val0, boolean sens0, + String name1, Object val1, boolean sens1, + String name2, Object val2, boolean sens2, + String name3, Object val3, boolean sens3, + String name4, Object val4, boolean sens4, + String name5, Object val5, boolean sens5, + String name6, Object val6, boolean sens6) { + assert cls != null; + assert obj != null; + assert name0 != null; + assert name1 != null; + assert name2 != null; + assert name3 != null; + assert name4 != null; + assert name5 != null; + assert name6 != null; + + Queue<GridToStringThreadLocal> queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] addNames = tmp.getAdditionalNames(); + Object[] addVals = tmp.getAdditionalValues(); + boolean[] addSens = tmp.getAdditionalSensitives(); + + addNames[0] = name0; + addVals[0] = val0; + addSens[0] = sens0; + addNames[1] = name1; + addVals[1] = val1; + addSens[1] = sens1; + addNames[2] = name2; + addVals[2] = val2; + addSens[2] = sens2; + addNames[3] = name3; + addVals[3] = val3; + addSens[3] = sens3; + addNames[4] = name4; + addVals[4] = val4; + addSens[4] = sens4; + addNames[5] = name5; + addVals[5] = val5; + addSens[5] = sens5; + addNames[6] = name6; + addVals[6] = val6; + addSens[6] = sens6; + + try { + return toStringImpl(cls, tmp.getStringBuilder(), obj, addNames, addVals, addSens, 7); + } + finally { + queue.offer(tmp); + } + } + + /** + * Produces auto-generated output of string presentation for given object and its declaration class. + * + * @param <T> Type of the object. + * @param cls Declaration class of the object. Note that this should not be a runtime class. + * @param obj Object to get a string presentation for. + * @param name0 Additional parameter name. + * @param val0 Additional parameter value. * @param name1 Additional parameter name. * @param val1 Additional parameter value. * @param name2 Additional parameter name. @@ -977,6 +1232,170 @@ public class GridToStringBuilder { } /** + * Produces uniformed output of string with context properties + * + * @param str Output prefix or {@code null} if empty. + * @param name0 Property name. + * @param val0 Property value. + * @param sens0 Property sensitive flag. + * @param name1 Property name. + * @param val1 Property value. + * @param sens1 Property sensitive flag. + * @param name2 Property name. + * @param val2 Property value. + * @param sens2 Property sensitive flag. + * @param name3 Property name. + * @param val3 Property value. + * @param sens3 Property sensitive flag. + * @param name4 Property name. + * @param val4 Property value. + * @param sens4 Property sensitive flag. + * @param name5 Property name. + * @param val5 Property value. + * @param sens5 Property sensitive flag. + * @return String presentation. + */ + public static String toString(String str, + String name0, @Nullable Object val0, boolean sens0, + String name1, @Nullable Object val1, boolean sens1, + String name2, @Nullable Object val2, boolean sens2, + String name3, @Nullable Object val3, boolean sens3, + String name4, @Nullable Object val4, boolean sens4, + String name5, @Nullable Object val5, boolean sens5) { + assert name0 != null; + assert name1 != null; + assert name2 != null; + assert name3 != null; + assert name4 != null; + assert name5 != null; + + Queue<GridToStringThreadLocal> queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] propNames = tmp.getAdditionalNames(); + Object[] propVals = tmp.getAdditionalValues(); + boolean[] propSens = tmp.getAdditionalSensitives(); + + propNames[0] = name0; + propVals[0] = val0; + propSens[0] = sens0; + propNames[1] = name1; + propVals[1] = val1; + propSens[1] = sens1; + propNames[2] = name2; + propVals[2] = val2; + propSens[2] = sens2; + propNames[3] = name3; + propVals[3] = val3; + propSens[3] = sens3; + propNames[4] = name4; + propVals[4] = val4; + propSens[4] = sens4; + propNames[5] = name5; + propVals[5] = val5; + propSens[5] = sens5; + + try { + return toStringImpl(str, tmp.getStringBuilder(), propNames, propVals, propSens, 6); + } + finally { + queue.offer(tmp); + } + } + + /** + * Produces uniformed output of string with context properties + * + * @param str Output prefix or {@code null} if empty. + * @param name0 Property name. + * @param val0 Property value. + * @param sens0 Property sensitive flag. + * @param name1 Property name. + * @param val1 Property value. + * @param sens1 Property sensitive flag. + * @param name2 Property name. + * @param val2 Property value. + * @param sens2 Property sensitive flag. + * @param name3 Property name. + * @param val3 Property value. + * @param sens3 Property sensitive flag. + * @param name4 Property name. + * @param val4 Property value. + * @param sens4 Property sensitive flag. + * @param name5 Property name. + * @param val5 Property value. + * @param sens5 Property sensitive flag. + * @param name6 Property name. + * @param val6 Property value. + * @param sens6 Property sensitive flag. + * @return String presentation. + */ + public static String toString(String str, + String name0, @Nullable Object val0, boolean sens0, + String name1, @Nullable Object val1, boolean sens1, + String name2, @Nullable Object val2, boolean sens2, + String name3, @Nullable Object val3, boolean sens3, + String name4, @Nullable Object val4, boolean sens4, + String name5, @Nullable Object val5, boolean sens5, + String name6, @Nullable Object val6, boolean sens6) { + assert name0 != null; + assert name1 != null; + assert name2 != null; + assert name3 != null; + assert name4 != null; + assert name5 != null; + assert name6 != null; + + Queue<GridToStringThreadLocal> queue = threadCache.get(); + + assert queue != null; + + // Since string() methods can be chain-called from the same thread we + // have to keep a list of thread-local objects and remove/add them + // in each string() apply. + GridToStringThreadLocal tmp = queue.isEmpty() ? new GridToStringThreadLocal() : queue.remove(); + + Object[] propNames = tmp.getAdditionalNames(); + Object[] propVals = tmp.getAdditionalValues(); + boolean[] propSens = tmp.getAdditionalSensitives(); + + propNames[0] = name0; + propVals[0] = val0; + propSens[0] = sens0; + propNames[1] = name1; + propVals[1] = val1; + propSens[1] = sens1; + propNames[2] = name2; + propVals[2] = val2; + propSens[2] = sens2; + propNames[3] = name3; + propVals[3] = val3; + propSens[3] = sens3; + propNames[4] = name4; + propVals[4] = val4; + propSens[4] = sens4; + propNames[5] = name5; + propVals[5] = val5; + propSens[5] = sens5; + propNames[6] = name6; + propVals[6] = val6; + propSens[6] = sens6; + + try { + return toStringImpl(str, tmp.getStringBuilder(), propNames, propVals, propSens, 7); + } + finally { + queue.offer(tmp); + } + } + + /** * Creates an uniformed string presentation for the binary-like object. * * @param str Output prefix or {@code null} if empty. http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringThreadLocal.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringThreadLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringThreadLocal.java index 33fc6a0..8ffacb3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringThreadLocal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringThreadLocal.java @@ -27,13 +27,13 @@ class GridToStringThreadLocal { private SB sb = new SB(256); /** */ - private Object[] addNames = new Object[5]; + private Object[] addNames = new Object[7]; /** */ - private Object[] addVals = new Object[5]; + private Object[] addVals = new Object[7]; /** */ - private boolean[] addSens = new boolean[5]; + private boolean[] addSens = new boolean[7]; /** * @return String builder. http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/test/java/org/apache/ignite/internal/SensitiveInfoTestLoggerProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/SensitiveInfoTestLoggerProxy.java b/modules/core/src/test/java/org/apache/ignite/internal/SensitiveInfoTestLoggerProxy.java new file mode 100644 index 0000000..89d3ce0 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/SensitiveInfoTestLoggerProxy.java @@ -0,0 +1,493 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.ignite.internal; + +import java.io.BufferedReader; +import java.io.Externalizable; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.InvalidObjectException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.io.ObjectStreamException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.internal.util.tostring.GridToStringInclude; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteBiTuple; +import org.apache.ignite.lifecycle.LifecycleAware; +import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.IgniteSystemProperties.IGNITE_LOG_GRID_NAME; + +/** + * + */ +public class SensitiveInfoTestLoggerProxy implements IgniteLogger, LifecycleAware, Externalizable { + /** + * If this system property is present the Ignite will test all strings passed into log. + * It's a special mode for testing purposes. All debug information will be generated, + * but only suspicious will be written into log with "error" level and special prefix SENSITIVE> + */ + public static final String IGNITE_LOG_TEST_SENSITIVE = "IGNITE_LOG_TEST_SENSITIVE"; + + /** Unique number for key. */ + public static final long SENSITIVE_KEY_MARKER = UUID.randomUUID().getLeastSignificantBits() | (1L << 63) & ~(0xFFL); + + /** Unique string sequence for value. */ + public static final String SENSITIVE_VAL_MARKER = UUID.randomUUID().toString(); + + /** String prefix of unique number for key. */ + private static final String SENSITIVE_KEY_MARKER_PREFIX; + + /** Indicating whether sensitive marker assertions enabled. */ + private static final AtomicBoolean ENABLE_SENSITIVE_MARKER_ASSERTIONS = new AtomicBoolean(); + + /** */ + private static final long serialVersionUID = 0L; + + /** Whether or not to log grid name. */ + private static final boolean logGridName = System.getProperty(IGNITE_LOG_GRID_NAME) != null; + + /** Test sensitive mode. */ + public static final boolean TEST_SENSITIVE = true;//System.getProperty(IGNITE_LOG_TEST_SENSITIVE) != null; + + /** Prefix for all suspicious sensitive data. */ + private static final String SENSITIVE_PREFIX = "SENSITIVE> "; + + /** Sensitive patterns: excluding. */ + private static final Pattern[] EXCLUDE_PATTERNS; + + /** Sensitive patterns: including. */ + private static final Pattern[] INCLUDE_PATTERNS; + + /** Excluding logger categories */ + private static final Pattern EXCLUDE_CATEGORY_P = Pattern.compile("Test(Task|Job)?($|\\$)|\\.tests?\\."); + + /** */ + private static ThreadLocal<IgniteBiTuple<String, Object>> stash = new ThreadLocal<IgniteBiTuple<String, Object>>() { + @Override protected IgniteBiTuple<String, Object> initialValue() { + return new IgniteBiTuple<>(); + } + }; + + /** */ + private static ThreadLocal<StringBuilder> sbLoc = new ThreadLocal<StringBuilder>() { + @Override protected StringBuilder initialValue() { + return new StringBuilder(SENSITIVE_PREFIX); + } + }; + + static { + String prefix = Long.toString(SENSITIVE_KEY_MARKER); + SENSITIVE_KEY_MARKER_PREFIX = prefix.substring(0, prefix.length() - 3); + } + + static { + EXCLUDE_PATTERNS = readFromResource("_Exclude.txt"); + INCLUDE_PATTERNS = readFromResource("_Include.txt"); + } + + /** */ + @GridToStringInclude + private IgniteLogger impl; + /** */ + private String gridName; + /** */ + private String id8; + /** */ + @GridToStringInclude + private Object ctgr; + + /** Whether testing sensitive is enabled for the logger */ + private boolean testSensitive; + /** + * No-arg constructor is required by externalization. + */ + public SensitiveInfoTestLoggerProxy() { + // No-op. + } + + /** + * @param impl Logger implementation to proxy to. + * @param ctgr Optional logger category. + * @param gridName Grid name (can be {@code null} for default grid). + * @param id8 Node ID. + */ + @SuppressWarnings({"IfMayBeConditional", "SimplifiableIfStatement"}) + public SensitiveInfoTestLoggerProxy(IgniteLogger impl, + @Nullable Object ctgr, + @Nullable String gridName, + String id8) { + assert impl != null; + + this.impl = impl; + this.ctgr = ctgr; + this.gridName = gridName; + this.id8 = id8; + this.testSensitive = TEST_SENSITIVE && (ctgr == null || !EXCLUDE_CATEGORY_P.matcher(ctgr.toString()).find()); + + if (TEST_SENSITIVE && ctgr == null && gridName == null && id8 == null) + impl.warning("Test sensitive mode is enabled"); + } + + /** + * Sets sensitive marker assertions flag. + * + * @param enable Flag value. + */ + public static void enableSensitiveMarkerAssertions(boolean enable) { + ENABLE_SENSITIVE_MARKER_ASSERTIONS.set(enable); + } + + /** + * Reads sensitive patterns from resource. + * + * @param suffix File name suffix. + * @return Read patterns. + */ + private static Pattern[] readFromResource(String suffix) { + ArrayList<Pattern> lst = new ArrayList<>(); + + final Class<SensitiveInfoTestLoggerProxy> cls = SensitiveInfoTestLoggerProxy.class; + + String resPath = cls.getSimpleName() + suffix; + + try (InputStream inStr = cls.getResourceAsStream(resPath); + BufferedReader rdr = new BufferedReader(new InputStreamReader(inStr))) { + String ln; + boolean skipComment = false; + + while ((ln = rdr.readLine()) != null) { + ln = ln.trim(); + + if (ln.isEmpty()) + continue; + + if (ln.startsWith("/*")) { + skipComment = true; + continue; + } + + if (ln.endsWith("*/")) { + skipComment = false; + continue; + } + + if (skipComment) + continue; + + lst.add(Pattern.compile(ln)); + } + } + catch (Exception ex) { + System.err.println("Error loading sensitive patterns from resource " + resPath + ": " + ex); + + ex.printStackTrace(); + } + + return lst.toArray(new Pattern[lst.size()]); + } + + /** + * @return Whether testing sensitive is enabled for the logger. + */ + private boolean testSensitiveEnabled() { + return testSensitive || ENABLE_SENSITIVE_MARKER_ASSERTIONS.get(); + } + + /** {@inheritDoc} */ + @Override public void start() { + if (impl instanceof LifecycleAware) + ((LifecycleAware)impl).start(); + } + + /** {@inheritDoc} */ + @Override public void stop() { + U.stopLifecycleAware(this, Collections.singleton(impl)); + } + + /** {@inheritDoc} */ + @Override public IgniteLogger getLogger(Object ctgr) { + assert ctgr != null; + + return new SensitiveInfoTestLoggerProxy(impl.getLogger(ctgr), ctgr, gridName, id8); + } + + /** {@inheritDoc} */ + @Nullable @Override public String fileName() { + return impl.fileName(); + } + + /** {@inheritDoc} */ + @Override public void trace(String msg) { + if (testSensitiveEnabled()) { + testSensitive(msg); + + if (impl.isTraceEnabled()) + impl.trace(enrich(msg)); + } + else + impl.trace(enrich(msg)); + } + + /** {@inheritDoc} */ + @Override public void debug(String msg) { + if (testSensitiveEnabled()) { + testSensitive(msg); + + if (impl.isDebugEnabled()) + impl.debug(enrich(msg)); + } + else + impl.debug(enrich(msg)); + } + + /** {@inheritDoc} */ + @Override public void info(String msg) { + if (testSensitiveEnabled()) { + testSensitive(msg); + + if (impl.isInfoEnabled()) + impl.info(enrich(msg)); + } + else + impl.info(enrich(msg)); + } + + /** {@inheritDoc} */ + @Override public void warning(String msg) { + if (testSensitiveEnabled()) + testSensitive(msg); + + impl.warning(enrich(msg)); + } + + /** {@inheritDoc} */ + @Override public void warning(String msg, Throwable e) { + if (testSensitiveEnabled()) + testSensitive(msg, e); + + impl.warning(enrich(msg), e); + } + + /** {@inheritDoc} */ + @Override public void error(String msg) { + if (testSensitiveEnabled()) + testSensitive(msg); + + impl.error(enrich(msg)); + } + + /** {@inheritDoc} */ + @Override public void error(String msg, Throwable e) { + if (testSensitiveEnabled()) + testSensitive(msg, e); + + impl.error(enrich(msg), e); + } + + /** {@inheritDoc} */ + @Override public boolean isTraceEnabled() { + return testSensitiveEnabled() || impl.isTraceEnabled(); + } + + /** {@inheritDoc} */ + @Override public boolean isDebugEnabled() { + return testSensitiveEnabled() || impl.isDebugEnabled(); + } + + /** {@inheritDoc} */ + @Override public boolean isInfoEnabled() { + return testSensitiveEnabled() || impl.isInfoEnabled(); + } + + /** {@inheritDoc} */ + @Override public boolean isQuiet() { + return !testSensitiveEnabled() && impl.isQuiet(); + } + + /** + * Enriches the log message with grid name if {@link IgniteSystemProperties#IGNITE_LOG_GRID_NAME} + * system property is set. + * + * @param m Message to enrich. + * @return Enriched message or the original one. + */ + private String enrich(@Nullable String m) { + return logGridName && m != null ? "<" + gridName + '-' + id8 + "> " + m : m; + } + + /** + * Testing the message by sensitive patterns.<br> + * All sensitive data will be logged with {@link #SENSITIVE_PREFIX} + * + * @param m Log message. + */ + private void testSensitive(String m) { + String f = findSensitive(m); + + if (f != null) + logSensitive(f, m); + } + + /** + * Testing the message and exceptions chain by sensitive patterns.<br> + * All sensitive data will be logged with {@link #SENSITIVE_PREFIX} + * + * @param m Log message. + * @param e Log error. + */ + private void testSensitive(String m, Throwable e) { + String f = findSensitive(m); + + if (f != null) + logSensitive(f, m, e); + + while (e != null) { + f = findSensitive(e.getMessage()); + + if (f != null) + logSensitive(f, m, e); + + e = e.getCause(); + } + } + + /** + * Check the message by sensitive patterns + * + * @param msg Log message. + * @return Matching string was found or {@code null} if not match. + */ + private String findSensitive(String msg) { + if (msg == null || msg.isEmpty()) + return null; + + if (ENABLE_SENSITIVE_MARKER_ASSERTIONS.get() && + msg.contains(SENSITIVE_KEY_MARKER_PREFIX) || msg.contains(SENSITIVE_VAL_MARKER)) { + + logSensitive("<MARKER>", msg); + + msg = msg.replace(SENSITIVE_KEY_MARKER_PREFIX, "<SENSITIVE_KEY_MARKER>"). + replace(SENSITIVE_VAL_MARKER, "<SENSITIVE_VAL_MARKER>"); + + throw new AssertionError("Found sensitive marker: " + msg); + } + + for (Pattern p : EXCLUDE_PATTERNS) { + Matcher m = p.matcher(msg); + + if (m.find()) + return null; + } + + for (Pattern p : INCLUDE_PATTERNS) { + Matcher m = p.matcher(msg); + + if (m.find()) + return m.group(); + } + + return null; + } + + /** + * Logging the message with {@link #SENSITIVE_PREFIX}. + * + * @param f Found problem message. + * @param m Logged message. + */ + private void logSensitive(String f, String m) { + logSensitive(f, m, null); + } + + /** + * Logging the message and the exception with {@link #SENSITIVE_PREFIX}. + * + * @param f Found problem message. + * @param m Logged message. + * @param e Logged exception. + */ + private void logSensitive(String f, String m, Throwable e) { + StringBuilder sb = sbLoc.get(); + + sb.setLength(SENSITIVE_PREFIX.length()); + + sb.append("Found: ").append(f). + append(", category = ").append(ctgr). + append(", message:\n").append(m); + + if (e != null) + sb.append("exception:\n").append(e.getClass()).append(": ").append(e.getMessage()); + + impl.error(sb.toString()); + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + U.writeString(out, gridName); + out.writeObject(ctgr); + } + + /** {@inheritDoc} */ + @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + IgniteBiTuple<String, Object> t = stash.get(); + + t.set1(U.readString(in)); + t.set2(in.readObject()); + } + + /** + * Reconstructs object on unmarshalling. + * + * @return Reconstructed object. + * @throws ObjectStreamException Thrown in case of unmarshalling error. + */ + protected Object readResolve() throws ObjectStreamException { + try { + IgniteBiTuple<String, Object> t = stash.get(); + + Object ctgrR = t.get2(); + + IgniteLogger log = IgnitionEx.localIgnite().log(); + + return ctgrR != null ? log.getLogger(ctgrR) : log; + } + catch (IllegalStateException e) { + throw U.withCause(new InvalidObjectException(e.getMessage()), e); + } + finally { + stash.remove(); + } + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(SensitiveInfoTestLoggerProxy.class, this); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/test/java/org/apache/ignite/internal/SensitiveInfoTestLoggerProxy_Exclude.txt ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/SensitiveInfoTestLoggerProxy_Exclude.txt b/modules/core/src/test/java/org/apache/ignite/internal/SensitiveInfoTestLoggerProxy_Exclude.txt new file mode 100644 index 0000000..1672ab1 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/SensitiveInfoTestLoggerProxy_Exclude.txt @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +^Received response to join request \[addr= +\[(msg(Id)?|job)=.+,\s*res=\d+\]$ +GC server mode is not enabled, this could lead to less than optimal performance on multi-core machines http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/test/java/org/apache/ignite/internal/SensitiveInfoTestLoggerProxy_Include.txt ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/SensitiveInfoTestLoggerProxy_Include.txt b/modules/core/src/test/java/org/apache/ignite/internal/SensitiveInfoTestLoggerProxy_Include.txt new file mode 100644 index 0000000..842efdb --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/SensitiveInfoTestLoggerProxy_Include.txt @@ -0,0 +1,18 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +(^|[^\.-])\b(k|keys?|v|vals?|(new|old|merge|loc)Vals?|rows?|fields?|params?|args?|items?|elements?|data|obj|res|result|clause|query|qry|sqlQry|ordinal|entrySet|keys?Set|vals?Set)\b\s*=\s*(?!\{?[\w-\.\$]*\s*[\[@])(?!null\b|true\b|false\b|BinaryEnum\b|class\s|\?\s).+?($|[,\[\]]) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveAtomicTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveAtomicTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveAtomicTest.java new file mode 100644 index 0000000..145c923 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveAtomicTest.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.ignite.internal.util.tostring; + +import org.apache.ignite.cache.CacheAtomicityMode; + +/** + * + */ +public class IncludeSensitiveAtomicTest extends IncludeSensitiveTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.ATOMIC; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveTest.java new file mode 100644 index 0000000..7328350 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveTest.java @@ -0,0 +1,149 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.ignite.internal.util.tostring; + +import javax.cache.processor.MutableEntry; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteSystemProperties; +import org.apache.ignite.cache.CacheEntryProcessor; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.SensitiveInfoTestLoggerProxy; +import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; + +/** + * Tests for property {@link IgniteSystemProperties#IGNITE_TO_STRING_INCLUDE_SENSITIVE}. + */ +public abstract class IncludeSensitiveTest extends GridCacheAbstractSelfTest { + /** Number of test entries */ + private static final int ENTRY_CNT = 10; + + /** + * @param i Index. + * @return Marked key by index. + */ + private static Long key(int i) { + return SensitiveInfoTestLoggerProxy.SENSITIVE_KEY_MARKER + i; + } + + /** + * @param i Index. + * @return Marked value by index. + */ + private static String value(int i) { + return SensitiveInfoTestLoggerProxy.SENSITIVE_VAL_MARKER + i; + } + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 3; + } + + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(IgniteConfiguration cfg, String cacheName) { + CacheConfiguration ccfg = super.cacheConfiguration(cfg, cacheName); + + ccfg.setBackups(1); + + return ccfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + + System.setProperty(IgniteSystemProperties.IGNITE_TO_STRING_INCLUDE_SENSITIVE, "false"); + + SensitiveInfoTestLoggerProxy.enableSensitiveMarkerAssertions(true); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + System.clearProperty(IgniteSystemProperties.IGNITE_TO_STRING_INCLUDE_SENSITIVE); + + SensitiveInfoTestLoggerProxy.enableSensitiveMarkerAssertions(false); + + super.afterTestsStopped(); + } + + /** Start transaction. */ + protected void startTx() { + // No-op. + } + + /** Commit transaction. */ + protected void commitTx() { + // No-op. + } + + /** + * Tests basic cache operations. + * + * @throws Exception If failed. + */ + public void test() throws Exception { + IgniteCache<Long, String> cache = grid(0).cache(DEFAULT_CACHE_NAME); + + startTx(); + + for (int i = 1; i < ENTRY_CNT; ++i) + cache.put(key(i), value(i)); + + commitTx(); + + cache.get(key(ENTRY_CNT / 2)); + + for (int i = 1; i < ENTRY_CNT; ++i) + cache.invoke(key(i), new TestEntryProcessor()); + + stopGrid(1); + + cache.rebalance().get(); + + for (int i = 0; i < ENTRY_CNT; ++i) + cache.get(key(i)); + + startGrid(1); + + cache.rebalance().get(); + + startTx(); + + for (int i = 1; i < ENTRY_CNT; ++i) + cache.remove(key(i)); + + commitTx(); + } + + /** + * + */ + static class TestEntryProcessor implements CacheEntryProcessor<Long, String, Object> { + /** {@inheritDoc} */ + @Override public Object process(MutableEntry<Long, String> entry, Object... args) { + long key = entry.getKey(); + + if (key % 2 == 0) + entry.remove(); + else + entry.setValue(entry.getValue() + "-"); + + return null; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveTransactionalTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveTransactionalTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveTransactionalTest.java new file mode 100644 index 0000000..0327171 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/IncludeSensitiveTransactionalTest.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.ignite.internal.util.tostring; + +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.transactions.Transaction; + +/** + * + */ +public class IncludeSensitiveTransactionalTest extends IncludeSensitiveTest { + /** Active transaction. */ + private Transaction tx; + + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.TRANSACTIONAL; + } + + /** {@inheritDoc} */ + @Override protected void startTx() { + tx = grid(0).transactions().txStart(); + } + + /** {@inheritDoc} */ + @Override protected void commitTx() { + tx.commit(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/b7d8d1b3/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java index 2c7d597..2222274 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java @@ -27,6 +27,7 @@ import javax.management.MBeanServer; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.SensitiveInfoTestLoggerProxy; import org.apache.ignite.internal.binary.BinaryCachingMetadataHandler; import org.apache.ignite.internal.binary.BinaryContext; import org.apache.ignite.internal.binary.BinaryMarshaller; @@ -74,9 +75,15 @@ public class IgniteTestResources { /** */ private GridResourceProcessor rsrcProc; - /** */ + /** + * @throws IgniteCheckedException If failed. + */ public IgniteTestResources() throws IgniteCheckedException { - log = rootLog.getLogger(getClass()); + if (SensitiveInfoTestLoggerProxy.TEST_SENSITIVE) + log = new SensitiveInfoTestLoggerProxy(rootLog.getLogger(getClass()), null, null, null); + else + log = rootLog.getLogger(getClass()); + nodeId = UUID.randomUUID(); jmx = ManagementFactory.getPlatformMBeanServer(); home = U.getIgniteHome();
