View Issue Details

IDProjectCategoryView StatusLast Update
0001188SymmetricDSImprovementpublic2014-02-03 01:53
Reporterjosema Assigned Tochenson  
Prioritynormal 
Status closedResolutionfixed 
Product Version3.3.5 
Target Version3.5.0Fixed in Version3.5.0 
Summary0001188: Inserting leading or trailing spaces in column ROUTER_EXPRESSION on table ROUTER produce ER in outgoing batch
DescriptionIf you insert incorrectly leading or trailing spaces in CLOB column ROUTER_EXPRESSION (when router type is lookuptable) key column, external id column can't be found in row resultset.
Outgoing Batch are processed in error state 'ER'.

 
Steps To ReproduceSample lookuptable expression:

LOOKUP_TABLE=V_SYM_ROUTER_LOOKUP
KEY_COLUMN=GEUS_GECU_ID
LOOKUP_KEY_COLUMN=GEUS_GECU_ID{tralingSpaces}
EXTERNAL_ID_COLUMN=USUI_ID_REF

If LOOKUP_KEY_COLUMN value after equals operator contains spaces before or after the name, is unable to locate column name during data retrieval.
Additional InformationI have tested next path in class that resolve issue:

Class name: org.jumpmind.symmetric.route.LookupTableDataRouter

Adding trim() method to the parsed tokens...

    public Map<String, String> parse(String routerExpression) throws SyntaxParsingException {
        boolean valid = true;
        Map<String, String> params = new HashMap<String, String>();
        if (!StringUtils.isBlank(routerExpression)) {
            String[] expTokens = routerExpression.split("\r\n|\r|\n");
            if (expTokens != null) {
                for (String t : expTokens) {
                    if (!StringUtils.isBlank(t)) {
                        String[] tokens = t.split("=");
                        /**
                         * tokens must be trimmed, removing leading and trailing spaces
                         */
                        if (tokens.length == 2 && !params.containsKey(tokens[0].trim())) {
                            params.put(tokens[0].trim(), tokens[1].trim());
                        } else {
                            valid = false;
                            break;
                        }
                    }
                }
                if (!valid ||
                    params.size() != 4 ||
                    !params.containsKey(PARAM_TABLE) ||
                    !params.containsKey(PARAM_KEY_COLUMN) ||
                    !params.containsKey(PARAM_MAPPED_KEY_COLUMN) ||
                    !params.containsKey(PARAM_EXTERNAL_ID_COLUMN)) {
                    
                    log.warn("The provided lookup table router expression was invalid. The full expression is " + routerExpression + ".");
                    throw new SyntaxParsingException("The provided lookup table router expression was invalid. The full expression is " + routerExpression + ".");
                }
            }
        }
        else {
            log.warn("The provided lookup table router expression is empty");
        }
        return params;
    }
TagsNo tags attached.

Activities

chenson

2013-04-26 20:54

administrator   ~0000249

Thanks for the suggestion!

chenson

2013-07-22 21:53

administrator   ~0000348

prepare for release

Related Changesets

SymmetricDS: master 8c0b0b4c

2013-04-26 16:54:06

chenson

Details Diff
0001188: Inserting leading or trailing spaces in column ROUTER_EXPRESSION on table ROUTER produce ER in outgoing batch Affected Issues
0001188
mod - symmetric-core/src/main/java/org/jumpmind/symmetric/route/LookupTableDataRouter.java Diff File

Issue History

Date Modified Username Field Change
2013-04-25 10:41 josema New Issue
2013-04-26 20:53 chenson Assigned To => chenson
2013-04-26 20:53 chenson Status new => assigned
2013-04-26 20:54 chenson Status assigned => resolved
2013-04-26 20:54 chenson Fixed in Version => 3.5.0
2013-04-26 20:54 chenson Resolution open => fixed
2013-04-26 20:54 chenson Note Added: 0000249
2013-04-26 20:54 chenson Target Version => 3.5.0
2013-07-22 21:53 chenson Note Added: 0000348
2013-07-22 21:53 chenson Status resolved => closed
2014-02-03 01:53 Changeset attached => SymmetricDS trunk r7128
2015-07-31 01:49 chenson Changeset attached => SymmetricDS master 8c0b0b4c