Skip to content

Commit

Permalink
Merge pull request #757 from Netflix/fix/set-max-characters
Browse files Browse the repository at this point in the history
Set the max character setting to Int.MAX.
  • Loading branch information
paulbakker authored Nov 19, 2024
2 parents cb9f828 + 6475cc6 commit 28eb116
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class CodeGen(private val config: CodeGenConfig) {

companion object {
private const val SDL_MAX_ALLOWED_SCHEMA_TOKENS: Int = Int.MAX_VALUE
private const val SDL_MAX_CHARACTERS: Int = Int.MAX_VALUE
private val logger: Logger = LoggerFactory.getLogger(CodeGen::class.java)
}

Expand Down Expand Up @@ -112,7 +113,10 @@ class CodeGen(private val config: CodeGenConfig) {
*/
private fun buildDocument(): Document {
val options = ParserOptions.getDefaultParserOptions().transform { builder ->
builder.maxTokens(SDL_MAX_ALLOWED_SCHEMA_TOKENS).maxWhitespaceTokens(SDL_MAX_ALLOWED_SCHEMA_TOKENS)
builder
.maxTokens(SDL_MAX_ALLOWED_SCHEMA_TOKENS)
.maxWhitespaceTokens(SDL_MAX_ALLOWED_SCHEMA_TOKENS)
.maxCharacters(SDL_MAX_CHARACTERS)
}
val parser = Parser()

Expand All @@ -139,7 +143,7 @@ class CodeGen(private val config: CodeGenConfig) {
parser.parseDocument(parserEnv)
} catch (exception: InvalidSyntaxException) {
// check if the schema is empty
if (exception.sourcePreview == null || exception.sourcePreview.isBlank()) {
if (exception.sourcePreview != null && exception.sourcePreview.isBlank()) {
logger.warn("Schema is empty")
// return an empty document
return Document.newDocument().build()
Expand Down

0 comments on commit 28eb116

Please sign in to comment.