Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reactor: refactor the code that does not comply with license requirements #7145

Open
wants to merge 8 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions saga/seata-saga-statemachine-designer/src/render/PathMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,28 @@

// helpers //////////////////////

// copied and adjusted from https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js
// Regular expression to match tokens in the format {tokenName}
const tokenRegex = /\{([^{}]+)\}/g;
const objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g; // matches .xxxxx or ["xxxxx"] to run over object properties
// Regular expression to match object property access using dot notation or bracket notation
// It captures properties accessed either directly (e.g., `obj.prop`)
// or indirectly (e.g., `obj['prop']` or `obj[prop]`), as well as function calls (e.g., `obj.method()`)
const objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g;

function replacer(all, key, obj) {
let res = obj;
key.replace(objNotationRegex, (_, name, quote, quotedName, isFunc) => {
name = name || quotedName;
if (res) {
if (name in res) {
res = res[name];
}
if (typeof res === 'function' && isFunc) {
res = res();
let result = obj;
key.replace(objNotationRegex, (_, name, quote, quotedName, isFunction) => {
const propertyName = name || quotedName;
if (result && propertyName in result) {
result = result[propertyName];

// If the result is a function and is marked as a function, call it to get a "real" value
if (typeof result === 'function' && isFunction) {
result = result();
}
}
});
res = `${res == null || res === obj ? all : res}`;

return res;
//Return the final alternative result, or all if result has not changed
return result == null || result === obj ? all : result;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be ${res == null || res === obj ? all : res} to convert res to string if necessary.

}

function format(str, obj) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,25 @@

import ch.qos.logback.classic.pattern.ExtendedThrowableProxyConverter;
import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.core.CoreConstants;

/**
* {@link ExtendedThrowableProxyConverter} that adds some additional whitespace around the
* stack trace.
* Copied from spring-boot-xxx.jar by wang.liang
*/
public class ExtendedWhitespaceThrowableProxyConverter extends ExtendedThrowableProxyConverter {
public class ExtendedArrowThrowableProxyConverter extends ExtendedThrowableProxyConverter {

public static final String SEPARATOR = System.getProperty("line.separator");
public static final String START_ARROW = "==> ";
public static final String END_ARROW = " <==";
@Override
protected String throwableProxyToString(IThrowableProxy tp) {
return "==>" + CoreConstants.LINE_SEPARATOR + super.throwableProxyToString(tp)
+ "<==" + CoreConstants.LINE_SEPARATOR + CoreConstants.LINE_SEPARATOR;
StringBuilder throwBuilder = new StringBuilder();
throwBuilder.append(START_ARROW)
.append(SEPARATOR)
.append(super.throwableProxyToString(tp))
.append(END_ARROW)
.append(SEPARATOR);
return throwBuilder.toString();
}

}
2 changes: 1 addition & 1 deletion server/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
<!-- The custom conversion rules -->
<conversionRule conversionWord="wEx2" converterClass="org.apache.seata.server.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx2" converterClass="org.apache.seata.server.logging.logback.ExtendedArrowThrowableProxyConverter"/>

<!-- common properties -->
<springProperty name="PORT" source="server.port" defaultValue="7091"/>
Expand Down
Loading