Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
485573fc
Commit
485573fc
authored
Feb 21, 2017
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1576: fix for NPE while handling unknown attributes
parent
b4a69415
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
AtlasStructFormatConverter.java
...las/repository/converters/AtlasStructFormatConverter.java
+14
-14
No files found.
repository/src/main/java/org/apache/atlas/repository/converters/AtlasStructFormatConverter.java
View file @
485573fc
...
@@ -23,6 +23,7 @@ import org.apache.atlas.exception.AtlasBaseException;
...
@@ -23,6 +23,7 @@ import org.apache.atlas.exception.AtlasBaseException;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.instance.AtlasStruct
;
import
org.apache.atlas.model.instance.AtlasStruct
;
import
org.apache.atlas.type.AtlasStructType
;
import
org.apache.atlas.type.AtlasStructType
;
import
org.apache.atlas.type.AtlasStructType.AtlasAttribute
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.typesystem.IStruct
;
import
org.apache.atlas.typesystem.IStruct
;
...
@@ -31,11 +32,8 @@ import org.apache.commons.collections.MapUtils;
...
@@ -31,11 +32,8 @@ import org.apache.commons.collections.MapUtils;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
public
class
AtlasStructFormatConverter
extends
AtlasAbstractFormatConverter
{
public
class
AtlasStructFormatConverter
extends
AtlasAbstractFormatConverter
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AtlasStructFormatConverter
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AtlasStructFormatConverter
.
class
);
...
@@ -119,22 +117,23 @@ public class AtlasStructFormatConverter extends AtlasAbstractFormatConverter {
...
@@ -119,22 +117,23 @@ public class AtlasStructFormatConverter extends AtlasAbstractFormatConverter {
return
ret
;
return
ret
;
}
}
protected
Map
<
String
,
Object
>
fromV2ToV1
(
AtlasStructType
structType
,
Map
attributes
,
ConverterContext
context
)
throws
AtlasBaseException
{
protected
Map
<
String
,
Object
>
fromV2ToV1
(
AtlasStructType
structType
,
Map
<
String
,
Object
>
attributes
,
ConverterContext
context
)
throws
AtlasBaseException
{
Map
<
String
,
Object
>
ret
=
null
;
Map
<
String
,
Object
>
ret
=
null
;
if
(
MapUtils
.
isNotEmpty
(
attributes
))
{
if
(
MapUtils
.
isNotEmpty
(
attributes
))
{
ret
=
new
HashMap
<>();
ret
=
new
HashMap
<>();
// Only process the requested/set attributes
// Only process the requested/set attributes
for
(
Object
attribKey
:
attributes
.
keySet
())
{
for
(
String
attrName
:
attributes
.
keySet
())
{
AtlasStructType
.
AtlasAttribute
attr
=
structType
.
getAttribute
((
String
)
attribKey
);
AtlasAttribute
attr
=
structType
.
getAttribute
(
attrName
);
AtlasType
attrType
=
attr
.
getAttributeType
();
if
(
attr
Type
==
null
)
{
if
(
attr
==
null
)
{
LOG
.
warn
(
"ignored
attribute {}.{}: failed to find AtlasType"
,
structType
.
getTypeName
(),
attr
.
getName
()
);
LOG
.
warn
(
"ignored
unknown attribute {}.{}"
,
structType
.
getTypeName
(),
attrName
);
continue
;
continue
;
}
}
AtlasType
attrType
=
attr
.
getAttributeType
();
Object
v2Value
=
attributes
.
get
(
attr
.
getName
());
Object
v2Value
=
attributes
.
get
(
attr
.
getName
());
Object
v1Value
;
Object
v1Value
;
...
@@ -155,15 +154,16 @@ public class AtlasStructFormatConverter extends AtlasAbstractFormatConverter {
...
@@ -155,15 +154,16 @@ public class AtlasStructFormatConverter extends AtlasAbstractFormatConverter {
// Only process the requested/set attributes
// Only process the requested/set attributes
for
(
Object
attribKey
:
attributes
.
keySet
())
{
for
(
Object
attribKey
:
attributes
.
keySet
())
{
AtlasStructType
.
AtlasAttribute
attr
=
structType
.
getAttribute
((
String
)
attribKey
);
String
attrName
=
attribKey
.
toString
();
AtlasAttribute
attr
=
structType
.
getAttribute
(
attrName
);
AtlasType
attrType
=
attr
.
getAttributeType
();
if
(
attr
==
null
)
{
LOG
.
warn
(
"ignored unknown attribute {}.{}"
,
structType
.
getTypeName
(),
attrName
);
if
(
attrType
==
null
)
{
LOG
.
warn
(
"ignored attribute {}.{}: failed to find AtlasType"
,
structType
.
getTypeName
(),
attr
.
getName
());
continue
;
continue
;
}
}
AtlasType
attrType
=
attr
.
getAttributeType
();
AtlasFormatConverter
attrConverter
=
converterRegistry
.
getConverter
(
attrType
.
getTypeCategory
());
AtlasFormatConverter
attrConverter
=
converterRegistry
.
getConverter
(
attrType
.
getTypeCategory
());
Object
v1Value
=
attributes
.
get
(
attr
.
getName
());
Object
v1Value
=
attributes
.
get
(
attr
.
getName
());
Object
v2Value
=
attrConverter
.
fromV1ToV2
(
v1Value
,
attrType
,
context
);
Object
v2Value
=
attrConverter
.
fromV1ToV2
(
v1Value
,
attrType
,
context
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment