Merge branch 'master' of github.com:alibaba/arthas

pull/213/head^2
hengyunabc 6 years ago
commit 16224993a9

@ -0,0 +1,28 @@
package com.taobao.arthas.core.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.junit.Assert;
import org.junit.Test;
/**
*
* @author brijeshprasad89
*
*/
public class DateUtilsTest {
@Test
public void testGetCurrentDateWithCorrectFormat() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //supported date format
Assert.assertEquals(DateUtils.getCurrentDate(),dateFormat.format(new Date()).toString());
}
@Test
public void testGetCurrentDateWithInCorrectFormat() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); // Not supported Date format
Assert.assertNotEquals(DateUtils.getCurrentDate(),dateFormat.format(new Date()).toString());
}
}

@ -1,4 +1,4 @@
Critical Fields in Expressions Fundamental Fields in Expressions
============================== ==============================
There is a very fundamental class `Advice` for the expressions used in filtering, tracing or monitoring and other aspects in commands. There is a very fundamental class `Advice` for the expressions used in filtering, tracing or monitoring and other aspects in commands.
@ -16,29 +16,29 @@ public class Advice {
private final boolean isBefore; private final boolean isBefore;
private final boolean isThrow; private final boolean isThrow;
private final boolean isReturn; private final boolean isReturn;
...
// getter/setter // getter/setter
} }
``` ```
Description for the variables in the class `Advice`:
|Name|Specification| |Name|Specification|
|---:|:---| |---:|:---|
|loader|class loader of the class| |loader|the class loader for the current called class|
|clazz|the reference of the class| |clazz|the reference to the current called class|
|method|the reflective reference of the method| |method|the reference to the current called method|
|target|the instance of the class| |target|the instance of the current called class|
|params|the parameters of the method, which is an array (when there is no argument in the method, it will be an empty array)| |params|the parameters for the current call, which is an array (when there's no parameter, it will be an empty array)|
|returnObj|the return value of the method - only when `isReturn==true`, it's a valid result but if the return value is `void` then it will be a `null`| |returnObj|the return value from the current call - only available when the method call returns normally (`isReturn==true`), and `null` is for `void` return value|
|throwExp|the exceptions thrown by the method invoking - only when `isThrow==true`, it's a valid thrown exception| |throwExp|the exceptions thrown from the current call - only available when the method call throws exception (`isThrow==true`)|
|isBefore|assistant checking flag used in [`before-watching` point](watch.md) and at this very moment: `isBefore==true`, `isThrow==false` and `isReturn==false` since it's before we invoke the method| |isBefore|flag to indicate the method is about to execute. `isBefore==true` but `isThrow==false` and `isReturn==false` since it's no way to know how the method call will end|
|isThrow|assistant checking flag: whether the current method invoking ends with exceptions| |isThrow|flag to indicate the method call ends with exception thrown|
|isReturn|assistant checking flag: whether the method invoking exits normally without exceptions| |isReturn|flag to indicate the method call ends normally without exception thrown|
F.Y.I All variables listed above can be used directly in the [OGNL expression](https://commons.apache.org/proper/commons-ognl/language-guide.html). The command will not execute and exit if there's illegal OGNL grammar or unexpected variable in the expression.
1. all the *fields* mentioned in the table above can be used directly in the `expressions`; * [typical use cases](https://github.com/alibaba/arthas/issues/71);
2. if the expressions are [invalid OGNL](https://en.wikipedia.org/wiki/OGNL), the command will be cancelled automatically with hints to correct the expressions; * [OGNL language guide](https://commons.apache.org/proper/commons-ognl/language-guide.html).
3. [typical use cases](https://github.com/alibaba/arthas/issues/71);
4. [OGNL official usage guide](https://commons.apache.org/proper/commons-ognl/language-guide.html).

Loading…
Cancel
Save